4
votes

I have added my REST api service in Azure API Management. I have followed all the steps given in this link Azure APIM. API works fine in local. It also works when accessed through published URL.

I have added OAuth2.0 security as well which is passing through fine.

My issue is When i try to access the operation through APIM published URL, the service is giving response 200 with empty content.

Can Someone please help.

2
Do you see forward-request policy statement in efective policy for that operation? - Vitaliy Kurokhtin
I checked, I have added only validate jwt token policy. - swathi
I followed the document and the API works well for me. What's the exact URL you were requesting? Did this API work when you test on the development portal? - Fei Xue - MSFT
No, even from developer portal I am getting same empty response. I am assuming that my request is not reaching API from APIM at all. - swathi
If you go to management portal, policies, select your product, API and operation and click Show effective policy button, what do you see there? - Vitaliy Kurokhtin

2 Answers

9
votes

This problem occurs when people unintentionally delete the top level policy and remove the main forward-request policy that applies to all operations on all apis. Simply click the Add policy button to re-add the default policy at the top level scope.

1
votes

Old question, but I'm posting because I had a similar issue (empty response) caused by a different issue:

I was getting empty responses as I had expressions in a policy that read the response. By default, reading the response clears it (presumably because its a stream underneath).

Found some good docs here: https://docs.microsoft.com/en-us/azure/api-management/api-management-transformation-policies#SetBody

I fixed this by specifying "preserve content" when reading the response:

JObject responseJobj = null;
if (context.Response.Body != null) 
{ 
    responseJobj = context.Response.Body.As<JObject>(preserveContent: true); 
}