Hi,
I am working on a project with OKTA users/groups api. I am trying to add/edit user/group in OKTA user management through .NET Core httpclient calls. But it failed in all user/user data, and gives error message “The request body was not well-formed.” always even when i have proper data.
Here is the code i am using.
var uri = “https://.oktapreview.com/api/v1/users?activate=true”;
using (var client = new HttpClient())
{
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri(uri)
};
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(“application/json”));
request.Headers.Authorization = new AuthenticationHeaderValue(“SSWS”, “”);
request.Content = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, “application/json”);
var response = await client.SendAsync(request);
var result = response.Content.ReadAsStringAsync().Result;
return JsonConvert.DeserializeObject(result);
}
data: {“Id”:null,“Status”:null,“Profile”:{“FirstName”:“demo”,“LastName”:“user”,“Email”:“demo.user12@crayon.com”,“Login”:“demo.user12@crayon.com”,“MobilePhone”:“1111111111”,“Department”:“Art”}}
OKTA Error: {“errorCode”:“E0000003”,“errorSummary”:“The request body was not well-formed.”,“errorLink”:“E0000003”,“errorId”:“oae2ca8eNAcRr6ahe4kgifAzg”,“errorCauses”:[]}
The same request is working fine in POSTMAN, its wired and surprise.
Someone can check this and give me a solution.
Thanks