none
Bad Request Error RRS feed

  • Question

  • I'm getting a bad request error. I'm not sure if I'm missing data or if my json format is bad. Postman seems to work:

    Postman:

    {
     "userName": "testuser3@aha.org",
     "mail": "testuser3@aha.org",
     "givenName": "Test",
     "sn": "User3",
     "accountStatus": "Active",
     "avectraId": "9999999678",
     "AHApw":
    "/Z5/5OXUBquzAtXesIjN0WjxFp1z05jMXKoynFyVKwa1+RdaUxmrFU6/nCOLedqh",
     "password" : "Password1",
     "ahaBirthYear" : "1980",
     "city" : "Chicago",
     "ahaGender" : "Female",
     "ahaJobTitle" : "CNO",
     "ahaLeadScore" : "101",
     "stateProvince" : "IL",
     "orgId" : "0006430024",
     "ahaMemberGroup" : [
     "AHA",
     "AONE"
     ],
     "ahaMemberType" : [
     "I-B",
      "FULL"
     ],
     "regMethod": "AMS"
    }

    My Code:

    IdentityDetails.username = "userName : " + tbIDM_UserName.Text;
                    IdentityDetails.mail = "mail : " + tbIDM_mail.Text;
                    IdentityDetails.givenName = "givenName : " + tbIDM_givenName.Text;
                    IdentityDetails.sn = "sn : " + tbIDM_sn.Text;
                    IdentityDetails.avectraId = "avectraId : " + tbIDM_avectraId.Text;
                    IdentityDetails.AHApw = "AHApw : " + tbIDM_AHApw.Text;
                    IdentityDetails.password = "password : " + tbIDM_password.Text;
                    IdentityDetails.ahaBirthYear = "ahaBirthYear : " + tbIDM_ahaBirthYear.Text;
                    IdentityDetails.city = "city : " + tbIDM_city.Text;
                    IdentityDetails.ahaGender = "ahaGender : " + tbIDM_ahaGender.Text;
                    IdentityDetails.ahaJobTitle = "ahaJobTitle : " + tbIDM_ahaJobTitle.Text;
                    IdentityDetails.ahaLeadScore = "ahaLeadScore : " + tbIDM_ahaLeadScore.Text;
                    IdentityDetails.stateProvince = "stateProvince : " + tbIDM_stateProvince.Text;
                    IdentityDetails.orgId = "orgId : " + tbIDM_orgId.Text;
                    IdentityDetails.regMethod = "regMethod : " + tbIDM_regMethod.Text;
                    IdentityDetails.ahaMemberGroup.Add("ahaMemberGroup : ", new string[] {tbIDM_ahaMemberGroup.Text});
                    IdentityDetails.ahaMemberType.Add("ahaMemberType : ", new string[] { tbIDM_ahaMemberType1.Text});


    Error:

    System.Net.WebException: The remote server returned an error: (400) Bad Request.
       at System.Net.WebClient.UploadDataInternal(Uri address, String method, Byte[] data, WebRequest& request)
       at System.Net.WebClient.UploadString(Uri address, String method, String data)
       at System.Net.WebClient.UploadString(String address, String method, String data)
       at AHARest.OpenIDM.PostCreateRequest(IdentityDetails obj) in C:\Users\mholmes\Documents\Visual Studio 2015\Projects\AHA_Identity_Management\AHARest\OpenIDM.cs:line 101

    • Edited by old_School Wednesday, October 18, 2017 4:14 PM
    Wednesday, October 18, 2017 4:11 PM

Answers

  • WEll those backslashes appear to be the issue according to stack over flow and other people had the same issue. However, I was able to get "RestSharp.Dll" which is Postmans open source dll. I think I almost got it working. Here is new code.

    public string _Post(IdentityDetails obj)
            {
                try
                {
                    var client = new RestClient("http://idm.aha-it.ahadatahub.com/openidm/managed/user?_action=create");
                    var request = new RestRequest(Method.POST);
                    string json = Regex.Unescape(JsonConvert.SerializeObject(obj, Newtonsoft.Json.Formatting.Indented));
                    request.AddHeader("postman-token", "31e04762-0ab3-21d0-b8b1-99cd0b17d7ba");
                    request.AddHeader("cache-control", "no-cache");
                    request.AddHeader("authorization", "Basic b3BlbmlkbS1hZG1pbjpvcGVuaWRtLWFkbWlu");
                    request.AddHeader("content-type", "application/json");
                    request.AddParameter("application/json", json, ParameterType.RequestBody);
                    IRestResponse response = client.Execute(request);
    
                    return response.Content.ToString();
                }
                catch(Exception ex)
                {
                    return ex.ToString();
                }
            }

    Getting this error now but I think I can fix it.     "{\"code\":403,\"reason\":\"Forbidden\",\"message\":\"Policy validation failed\",\"detail\":{\"result\":false,\"failedPolicyRequirements\":[{\"policyRequirements\":[{\"policyRequirement\":\"SHOULD_BE_SAME_AS_EMAIL\"}],\"property\":\"userName\"},{\"policyRequirements\":[{\"policyRequirement\":\"REQUIRED\"}],\"property\":\"userName\"},{\"policyRequirements\":[{\"regexp\":\"\",\"flags\":null,\"params\":{\"regexp\":\"\"},\"policyRequirement\":\"MATCH_REGEXP\"}],\"property\":\"userName\"}]}}"

    Edit

    Marking this as answer because the issue is my class it appears. It does not match Postman when I try to build the class.

    • Marked as answer by old_School Friday, October 20, 2017 5:55 PM
    • Edited by old_School Friday, October 20, 2017 5:56 PM
    Friday, October 20, 2017 4:50 PM

All replies

  • You haven't actually described how you are converting your IdentityDetails object into a JSON object or making the request.

    Either post that or debug at the point where the request is being made and examine what is actually getting sent.

    Wednesday, October 18, 2017 4:15 PM
  • Oh sorry, here you go. Just serializing it

    public string PostCreateRequest(IdentityDetails obj)
            {
                try
                {
                    //Create Account
                    string Response = string.Empty;
                    string url = _EndPoint + "?_action=create";
                    string username = "openidm-admin";
                    string password = "openidm-admin";
                    
                    string svcCredentials = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(username + ":" + password));
                    var json = new JavaScriptSerializer().Serialize(obj);
    
                    using (var client = new WebClient())
                    {
                        client.Headers.Add("Authorization", "Basic " + svcCredentials);
    
                        Response = client.UploadString(url, "POST", json);
                    }
    
                    return Response;
                }
                catch (Exception ex)
                {
                    return ex.ToString();
                }
            }

    Wednesday, October 18, 2017 5:19 PM
  • I have changed my code but still getting bad request error:

    code:

    public string PostCreateRequest(IdentityDetails obj)
            {
                try
                {
                    string url = _EndPoint + "?_action=create";
                    var request = HttpWebRequest.Create(url);
                    var json = new JavaScriptSerializer().Serialize(obj);
                    //var postData = "Jlpt = 2";
                    var data = Encoding.ASCII.GetBytes(json);
                    string username = "openidm-admin";
                    string password = "openidm-admin";
                    string svcCredentials = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(username + ":" + password));
    
                    request.Method = "POST";
                    request.ContentType = "application/x-www-form-urlencoded";
                    request.ContentLength = data.Length;
                    request.Headers.Add("Authorization", "Basic " + svcCredentials);
    
                    using (var stream = request.GetRequestStream())
                    {
                        stream.Write(data, 0, data.Length);
                    }
    
                    var response = (HttpWebResponse)request.GetResponse();
    
                    var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
    
                    return responseString;
                }
                catch(Exception ex)
                {
                    return ex.ToString();
                }
            }

    Error:

    System.Net.WebException: The remote server returned an error: (400) Bad Request.
       at System.Net.HttpWebRequest.GetResponse()
       at AHARest.OpenIDM.PostCreateRequest(IdentityDetails obj) in C:\Users\mholmes\Documents\Visual Studio 2015\Projects\AHA_Identity_Management\AHARest\OpenIDM.cs:line 107

    Edit:

    here is the response via json:

    {\"AccountStatus\":\"\\\"accountStatus\\\"Active\",\"username\":\"userName : testuser444@aha.org\",\"mail\":\"mail : testuser444@aha.org\",\"givenName\":\"givenName : Test\",\"sn\":\"sn : user444\",\"avectraId\":\"avectraId : 9999999678\",\"AHApw\":\"AHApw : /Z5/5OXUBquzAtXesIjN0WjxFp1z05jMXKoynFyVKwa1+RdaUxmrFU6/nCOLedqh\",\"password\":\"password : Password1\",\"ahaBirthYear\":\"ahaBirthYear : 1980\",\"city\":\"city : Chicago\",\"ahaGender\":\"ahaGender : Female\",\"ahaJobTitle\":\"ahaJobTitle : CNO\",\"ahaLeadScore\":\"ahaLeadScore : 101\",\"stateProvince\":\"stateProvince : IL\",\"orgId\":\"orgId : 0006430024\",\"regMethod\":\"regMethod : AMS\",\"ahaMemberType\":{\"ahaMemberType : \":[\"I-8\"]},\"ahaMemberGroup\":{\"ahaMemberGroup : \":[\"AHA\"]}}

    • Edited by old_School Wednesday, October 18, 2017 6:30 PM
    Wednesday, October 18, 2017 5:56 PM
  • I am not too familiar with the JavaScriptSerializer, but you only have to look at the resulting JSON to see that, because you have included the field names as the data, you are just going to get the field name included twice.

    E.g. Because you have

    IdentityDetails.username = "userName : " + tbIDM_UserName.Text;


    You end up with

    \"username\":\"userName : testuser444@aha.org\"


    The object's data should be just that - the data. You should not need to include the field names again:

    IdentityDetails.userName = tbIDM_UserName.Text;

    The serializer will take the names of the properties themselves (e.g. userName) and that will be built into the JSON. Typically the property name is taken directly - meaning you have make sure you get the case correct - but you can usually control the exact format by decorating the property with specific attributes (although the JavaSciptSerializer may work differently; as I said, I'm not familiar with that one, so you should look up the documentation).


    • Edited by RJP1973 Thursday, October 19, 2017 7:00 AM
    Thursday, October 19, 2017 7:00 AM
  • Thanks, I'll give it a try

    Edit:

    I tried that but still get bad request. I think that might be part of the issue but something else is wrong. Here is my adjusted code for fixing the json string issue.

     private bool Build_IdentityDetails()
            {           
                try
                {                
                    bool IDM_Setup = true;
    
                    if (tbIDM_UserName.Text == string.Empty | tbIDM_mail.Text == string.Empty | tbIDM_givenName.Text == string.Empty | tbIDM_sn.Text == string.Empty
                         | tbIDM_avectraId.Text == string.Empty | tbIDM_AHApw.Text == string.Empty | tbIDM_password.Text == string.Empty | tbIDM_ahaBirthYear.Text == string.Empty
                          | tbIDM_city.Text == string.Empty | tbIDM_ahaGender.Text == string.Empty | tbIDM_ahaJobTitle.Text == string.Empty | tbIDM_ahaLeadScore.Text == string.Empty
                           | tbIDM_stateProvince.Text == string.Empty | tbIDM_orgId.Text == string.Empty | tbIDM_ahaMemberGroup.Text == string.Empty | tbIDM_ahaMemberType1.Text == string.Empty)
                    { 
                        return false;
                    }
    
                    List<string> lstgroups = new List<string>();
                    List<string> lstmembertype = new List<string>();
                    //IdentityDetails.ahaMemberGroup = new Dictionary<string, string[]>();
                    //IdentityDetails.ahaMemberType = new Dictionary<string, string[]>();
    
                    //IdentityDetails.username = '"' + "userName" + '"' + " : " + '"' + tbIDM_UserName.Text + '"';
                    //IdentityDetails.mail = '"' + "mail" + '"' + " : " + '"' + tbIDM_mail.Text + '"';
                    //IdentityDetails.givenName = '"' + "givenName" + '"' + " : " + tbIDM_givenName.Text + '"';
                    //IdentityDetails.sn = '"' + "sn" + '"' + " : " + '"' + tbIDM_sn.Text + '"';
                    //IdentityDetails.avectraId = '"' + "avectraId" + '"' + " : " + '"' + tbIDM_avectraId.Text + '"';
                    //IdentityDetails.AHApw = '"' + "AHApw" + '"' + " : " + '"' + tbIDM_AHApw.Text + '"';
                    //IdentityDetails.password = '"' + "password" + '"' + " : " + '"' + tbIDM_password.Text + '"';
                    //IdentityDetails.ahaBirthYear = '"' + "ahaBirthYear" + '"' + " : " + '"' + tbIDM_ahaBirthYear.Text + '"';
                    //IdentityDetails.city = '"' + "city" + '"' + " : " + '"' + tbIDM_city.Text + '"';
                    //IdentityDetails.ahaGender = '"' + "ahaGender" + '"' + " : " + '"' + tbIDM_ahaGender.Text + '"';
                    //IdentityDetails.ahaJobTitle = '"' + "ahaJobTitle" + '"' + " : " + '"' + tbIDM_ahaJobTitle.Text + '"';
                    //IdentityDetails.ahaLeadScore = '"' + "ahaLeadScore" + '"' + " : " + '"' + tbIDM_ahaLeadScore.Text + '"';
                    //IdentityDetails.stateProvince = '"' + "stateProvince" + '"' + " : " + '"' + tbIDM_stateProvince.Text + '"';
                    //IdentityDetails.orgId = '"' + "orgId" + '"' + " : " + '"' + tbIDM_orgId.Text + '"';
                    //IdentityDetails.regMethod = '"' + "regMethod" + '"' + " : " + '"' + tbIDM_regMethod.Text + '"';
                    //IdentityDetails.ahaMemberGroup.Add('"' + "ahaMemberGroup" + '"' + " : ", new string[] { '"' + tbIDM_ahaMemberGroup.Text + '"'});
                    //IdentityDetails.ahaMemberType.Add('"' + "ahaMemberType" + '"' + " : ", new string[] { '"' + tbIDM_ahaMemberType1.Text + '"' });
    
                    //IdentityDetails.username = "userName : " + tbIDM_UserName.Text;
                    //IdentityDetails.mail = "mail : " + tbIDM_mail.Text;
                    //IdentityDetails.givenName = "givenName : " + tbIDM_givenName.Text;
                    //IdentityDetails.sn = "sn : " + tbIDM_sn.Text;
                    //IdentityDetails.avectraId = "avectraId : " + tbIDM_avectraId.Text;
                    //IdentityDetails.AHApw = "AHApw : " + tbIDM_AHApw.Text;
                    //IdentityDetails.password = "password : " + tbIDM_password.Text;
                    //IdentityDetails.ahaBirthYear = "ahaBirthYear : " + tbIDM_ahaBirthYear.Text;
                    //IdentityDetails.city = "city : " + tbIDM_city.Text;
                    //IdentityDetails.ahaGender = "ahaGender : " + tbIDM_ahaGender.Text;
                    //IdentityDetails.ahaJobTitle = "ahaJobTitle : " + tbIDM_ahaJobTitle.Text;
                    //IdentityDetails.ahaLeadScore = "ahaLeadScore : " + tbIDM_ahaLeadScore.Text;
                    //IdentityDetails.stateProvince = "stateProvince : " + tbIDM_stateProvince.Text;
                    //IdentityDetails.orgId = "orgId : " + tbIDM_orgId.Text;
                    //IdentityDetails.regMethod = "regMethod : " + tbIDM_regMethod.Text;
                    //IdentityDetails.ahaMemberGroup.Add("ahaMemberGroup : ", new string[] {tbIDM_ahaMemberGroup.Text});
                    //IdentityDetails.ahaMemberType.Add("ahaMemberType : ", new string[] { tbIDM_ahaMemberType1.Text});
    
                    IdentityDetails.username = tbIDM_UserName.Text;
                    IdentityDetails.mail = tbIDM_mail.Text;
                    IdentityDetails.givenName = tbIDM_givenName.Text;
                    IdentityDetails.sn = tbIDM_sn.Text;
                    IdentityDetails.avectraId = tbIDM_avectraId.Text;
                    IdentityDetails.AHApw = tbIDM_AHApw.Text;
                    IdentityDetails.password = tbIDM_password.Text;
                    IdentityDetails.ahaBirthYear = tbIDM_ahaBirthYear.Text;
                    IdentityDetails.city = tbIDM_city.Text;
                    IdentityDetails.ahaGender = tbIDM_ahaGender.Text;
                    IdentityDetails.ahaJobTitle = tbIDM_ahaJobTitle.Text;
                    IdentityDetails.ahaLeadScore = tbIDM_ahaLeadScore.Text;
                    IdentityDetails.stateProvince = tbIDM_stateProvince.Text;
                    IdentityDetails.orgId = tbIDM_orgId.Text;
                    IdentityDetails.regMethod = tbIDM_regMethod.Text;
                    lstgroups.Add(tbIDM_ahaMemberGroup.Text);
                    IdentityDetails.ahaMemberGroup = lstgroups.ToArray();
                    lstmembertype.Add(tbIDM_ahaMemberType1.Text);
                    IdentityDetails.ahaMemberType = lstmembertype.ToArray();
    
                    return IDM_Setup;
                }
                catch(Exception ex)
                {
                    return false;
                }
            }


    Current Json string:

    "{\"AccountStatus\":\"Active\",\"username\":\"testuser99@aha.org\",\"mail\":\"testuser3@aha.org\",\"givenName\":\"Test\",\"sn\":\"user99\",\"avectraId\":\"9999999678\",\"AHApw\":\"/Z5/5OXUBquzAtXesIjN0WjxFp1z05jMXKoynFyVKwa1+RdaUxmrFU6/nCOLedqh\",\"password\":\"Password1\",\"ahaBirthYear\":\"1980\",\"city\":\"Chicago\",\"ahaGender\":\"Female\",\"ahaJobTitle\":\"CNO\",\"ahaLeadScore\":\"101\",\"stateProvince\":\"IL\",\"orgId\":\"0006430024\",\"regMethod\":\"\",\"ahaMemberType\":[\"I-8\"],\"ahaMemberGroup\":[\"AHA\"]}"

    Edit:

    I have made a few adjustments to match Postman as closely as I can;

    current json string request:

    "{\"username\":\"testuser44@aha.org\",\"mail\":\"testuser44@aha.org\",\"givenName\":\"Test\",\"sn\":\"testuser44\",\"accountStatus\":\"Active\",\"avectraId\":\"9999999678\",\"AHApw\":\"/Z5/5OXUBquzAtXesIjN0WjxFp1z05jMXKoynFyVKwa1+RdaUxmrFU6/nCOLedqh\",\"password\":\"Password1\",\"ahaBirthYear\":\"1980\",\"city\":\"test\",\"ahaGender\":\"Female\",\"ahaJobTitle\":\"CNO\",\"ahaLeadScore\":\"101\",\"stateProvince\":\"IL\",\"orgId\":\"0006430024\",\"ahaMemberGroup\":[\"AONE\"],\"ahaMemberType\":[\"FULL\"],\"regMethod\":\"AMS\"}"

    • Edited by old_School Friday, October 20, 2017 3:16 PM
    Friday, October 20, 2017 1:13 PM
  • Updated my code to this now getting a 403 forbidden error. That means my authentication failed correct?

     public string PostCreateRequest(IdentityDetails obj)
            {
                try
                {
                    string url = _EndPoint + "?_action=create";
                    var request = HttpWebRequest.Create(url);
                    var json = new JavaScriptSerializer().Serialize(obj);
                    var data = Encoding.ASCII.GetBytes(json);
                    string username = "openidm-admin";
                    string password = "openidm-admin";
                    string svcCredentials = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(username + ":" + password));
    
                    request.Method = "POST";
                    //request.ContentType = "application/x-www-form-urlencoded";
                    request.ContentType = "application/json";
                    request.ContentLength = data.Length;
                    request.Headers.Add("Authorization", "Basic " + svcCredentials);
    
                    using (var stream = request.GetRequestStream())
                    {
                        stream.Write(data, 0, data.Length);
                    }
    
                    var response = (HttpWebResponse)request.GetResponse();
    
                    var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
    
                    return responseString;
                }
                catch(Exception ex)
                {
                    return ex.ToString();
                }
            }

    Friday, October 20, 2017 3:32 PM
  • Sort of. According to the other wiki, error 401 typically means unauthorized whereas 403 is the server is telling you that you do not have permission to do whatever operation you have requested
    Friday, October 20, 2017 3:43 PM
  • Changed the code again to match the documentation a little better but now I'm getting a forbidden error. I also fixed my Json string. It looks like .Net adds "\" to the json string. So I fixed that, now I get this json string:

    String:

    "{\r\n  \"username\": \"testuser70@aha.org\",\r\n  \"mail\": \"testuser70@aha.org\",\r\n  \"givenName\": \"test\",\r\n  \"sn\": \"user70\",\r\n  \"accountStatus\": \"Active\",\r\n  \"avectraId\": \"9999999678\",\r\n  \"AHApw\": \"/Z5/5OXUBquzAtXesIjN0WjxFp1z05jMXKoynFyVKwa1+RdaUxmrFU6/nCOLedqh\",\r\n  \"password\": \"Password1\",\r\n  \"ahaBirthYear\": \"1980\",\r\n  \"city\": \"tester\",\r\n  \"ahaGender\": \"Female\",\r\n  \"ahaJobTitle\": \"CNO\",\r\n  \"ahaLeadScore\": \"101\",\r\n  \"stateProvince\": \"IL\",\r\n  \"orgId\": \"0006430024\",\r\n  \"ahaMemberGroup\": [\r\n    \"AONE\"\r\n  ],\r\n  \"ahaMemberType\": [\r\n    \"FULL\"\r\n  ],\r\n  \"regMethod\": \"AMS\"\r\n}"

    Code:

    public string PostCreateRequest(IdentityDetails obj)
            {
                try
                {
                    string url = _EndPoint + "?_action=create";
                    var request = HttpWebRequest.Create(url);
                    string json = Regex.Unescape(JsonConvert.SerializeObject(obj, Newtonsoft.Json.Formatting.Indented));
                    //var json = new JavaScriptSerializer().Serialize(obj);
                    var data = Encoding.ASCII.GetBytes(json);
                    string username = "openidm-admin";
                    string password = "openidm-admin";
                    string svcCredentials = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(username + ":" + password));
    
                    request.Method = "POST";
                    //request.ContentType = "application/x-www-form-urlencoded";
                    request.ContentType = "application/json";
                    request.ContentLength = data.Length;
                    request.Headers.Add("Authorization", "Basic " + svcCredentials);
    
                    using (var stream = request.GetRequestStream())
                    {
                        stream.Write(data, 0, data.Length);
                    }
    
                    var response = (HttpWebResponse)request.GetResponse();
    
                    var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
    
                    return responseString;
                }
                catch(Exception ex)
                {
                    return ex.ToString();
                }
            }

    Error:

    The remote server returned an error: (403) Forbidden.

    Friday, October 20, 2017 3:55 PM
  • How are you looking at your JSON string?

    Because if you are looking at it via the Visual Studio debugger you need to be aware that the debugger will show you the string with all special characters escaped. e.g. a double-quote will appear as \" and a carriage-return will appear as \r.

    That would explain all your extra backslashes. This isn't how your string actually is (otherwise I don't think it would be valid JSON) - it's just how the visual studio debugger displays it.

    (I know this doesn't answer your 403 issue, but just didn't want you distracted by a red herring!)
    • Edited by RJP1973 Friday, October 20, 2017 4:05 PM
    Friday, October 20, 2017 4:04 PM
  • WEll those backslashes appear to be the issue according to stack over flow and other people had the same issue. However, I was able to get "RestSharp.Dll" which is Postmans open source dll. I think I almost got it working. Here is new code.

    public string _Post(IdentityDetails obj)
            {
                try
                {
                    var client = new RestClient("http://idm.aha-it.ahadatahub.com/openidm/managed/user?_action=create");
                    var request = new RestRequest(Method.POST);
                    string json = Regex.Unescape(JsonConvert.SerializeObject(obj, Newtonsoft.Json.Formatting.Indented));
                    request.AddHeader("postman-token", "31e04762-0ab3-21d0-b8b1-99cd0b17d7ba");
                    request.AddHeader("cache-control", "no-cache");
                    request.AddHeader("authorization", "Basic b3BlbmlkbS1hZG1pbjpvcGVuaWRtLWFkbWlu");
                    request.AddHeader("content-type", "application/json");
                    request.AddParameter("application/json", json, ParameterType.RequestBody);
                    IRestResponse response = client.Execute(request);
    
                    return response.Content.ToString();
                }
                catch(Exception ex)
                {
                    return ex.ToString();
                }
            }

    Getting this error now but I think I can fix it.     "{\"code\":403,\"reason\":\"Forbidden\",\"message\":\"Policy validation failed\",\"detail\":{\"result\":false,\"failedPolicyRequirements\":[{\"policyRequirements\":[{\"policyRequirement\":\"SHOULD_BE_SAME_AS_EMAIL\"}],\"property\":\"userName\"},{\"policyRequirements\":[{\"policyRequirement\":\"REQUIRED\"}],\"property\":\"userName\"},{\"policyRequirements\":[{\"regexp\":\"\",\"flags\":null,\"params\":{\"regexp\":\"\"},\"policyRequirement\":\"MATCH_REGEXP\"}],\"property\":\"userName\"}]}}"

    Edit

    Marking this as answer because the issue is my class it appears. It does not match Postman when I try to build the class.

    • Marked as answer by old_School Friday, October 20, 2017 5:55 PM
    • Edited by old_School Friday, October 20, 2017 5:56 PM
    Friday, October 20, 2017 4:50 PM