Azure API Management POST API works in test but not in Postman

I have set up an API management POST API operation that reads the incoming body and creates variables from the values in the policy, passing it on as query variables to the backend API call and returning the result.

Sample:

<set-variable name="TaskName" value="@{if (context.Request.Body != null){ return (string)context.Request.Body.As<JObject>(preserveContent: true).SelectToken("TaskName");} else {return "";}}" />

This works when I send a body in the Azure the APIM Test area that looks like this:

<set-query-parameter name="TaskName" exists-action="append"> <value>@((string)context.Variables["TaskName"])</value> </set-query-parameter>

However, it DOES NOT work when submitting a request in POSTMAN - it renders a 500 status code. For the record, I created a GET API operation in the same APIM API that accepts Query Variables and passes them on as query variables to the backend API call. This works both in test and in POSTMAN. Lastly, if I establish a Representation inside AZURE APIM on the POST API call, it no longer works in the APIM Test area. The external API being called is a webAPI hosted by my company on a different server.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.