You'll need to add an on-error
policy and use it in conjunction with the set-body
policy to ensure the response body coming from your API is carried over to the response that the caller receives. In order to implement it, please review the following:
Why is Azure API Management hides response body for status codes 4** and 5**

I created an API in Azure API Management and I realized that APIM actually hides some of the bodies I return.
I get 200, but I don't get 404, 401 and 500.
I understand that it's better to control what is returned and that we don't want to give the end-user HTML with 500 error body.
I use 404 or 401 in my API along with returning messages to the user. Is there a possibility to control what is being returned for certain status codes?
2 answers
Sort by: Most helpful
-
Mike Urnun 5,501 Reputation points
2020-05-23T19:24:50.157+00:00 Dan Cundy 1 Reputation point2021-08-09T09:56:25.6+00:00 Hi @Mike Urnun
After following the documentation at the error management page below and adding the error policy sample into the
<on-error>
sectionapi-management-error-handling-policies
I'm still getting my 401 Reponses masked with a 500. Does that sounds like correct behaviour?