The PostAsJsonAsync returns a bad request when calling the “/api/v1/users?activate=true” web api in our PROD environment.
I can run the C# code against a DEV environment without error. Our okta admin resetted the token after granting admin access to the service account used to generate the token, no luck.
A part from the web service endpoint and the token, there are no difference in the C# between development and our real okta environment. Obvisously, I am missing some header or body element, but why?
I can create a usewr if I call the api with Postman, so the problem really lies within an additional setup required in dotnet.
Do you have any more details about the cause of the bad request, like a full error description/summary? For example, does it say the request body is malformed or that the body was missing a required attribute for user creation?
If the .NET HTTPREsponseMessage won’t return that information, what about if you check the raw network calls being made on this machine? That way you can see the full response body. You should get more information back from Okta about the cause of the 400.
PS, we usually expect Content-Type to be set to application/json, so it could be as simple as that header missing.
I finally found the problem after reviewing every lines of code (not a big project anyway). I had a custom user profile property field in the DEV environment not found in the PROD; winded up not using it after all and it was not reference in the userModel property assigned… but since it exists in the class definition, the json initialized does refer to it. So DEV was happy, but PROD was getting a request with an unknown property reference.