I am just trying to make a simple post to create a single user, but receiving error “The request body was not well-formed.”. Exact same request in Postman works fine.
Here is the API method (please note that the JsonConvert.SerializeObject in the first line was an attempt to get the JSON normalized. Leaving the jsonData as is still produces the same error):
[HttpPost]
public object CreateUser([FromBody] dynamic jsonData)
{
var body = JsonConvert.SerializeObject(jsonData);
System.Console.WriteLine(body);
var client = new RestClient();
client.BaseUrl = new System.Uri("https://testurl.com/");
var request = new RestRequest(Method.POST);
request.AddHeader("Accept","application/json");
request.AddHeader("Content-Type","application/json");
request.AddHeader("Authorization","{{AuthToken}}");
request.Resource = "api/v1/users/activate=true";
request.RequestFormat = DataFormat.Json;
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
return response.Content;
}
The Console.WriteLine returns this:
{ "profile": { "firstName": "john", "lastName": "doe", "email": "test@test.com", "login": "test@test.com" }, "credentials": { "password" : { "value": "Testing1234" } }, "groupIds": [ "{{groupID}}" ] }
The above JSON is exactly the same as what works perfectly fine when running the request through Postman.
I’ve seen suggestions to use the SDK, but given the fact that it is in alpha still and doesn’t access the full API yet I would rather just do it manually until it is in a more final state.
Any help is appreciated.