POST API in API Management renders 500 when the incoming body has header content-type:application/json

Robert Heynen 50 Reputation points
2023-04-14T03:11:10.8933333+00:00

I set up a POST API Operation in an API Management API. Anytime I try to submit a request with a Header Content-Type: application/json, I get a 500 Status code. I tried setting it as a representation and that did not work If I remove the header item, the call works without issue. The body is standard Json.

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,448 questions
{count} votes

Accepted answer
  1. MuthuKumaranMurugaachari-MSFT 22,441 Reputation points Moderator
    2023-04-14T22:38:25.33+00:00

    Robert Heynen Thanks again for sharing the details.

    Update for the community:

    Robert captured a trace using Trace a call and found that APIM generated a request with query parameters to backend, but backend API was rejecting the request when header content-type was set as application/json . He also validated the same via Postman as well. So, he overrides header value by setting content-type as text/plain in APIM policy and it worked. I hope this helps with your questions and let us know if you have any other.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.