question

MariuszKlimek avatar image
0 Votes"
MariuszKlimek asked DanCundy-7289 edited

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?

azure-api-management
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MikeUrnun avatar image
0 Votes"
MikeUrnun answered MikeUrnun commented

Hi @MariuszKlimek

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:

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@MariuszKlimek Just following up here on my answer above, let us know if there are any further questions and we'd be happy to assist.

0 Votes 0 ·
DanCundy-7289 avatar image
0 Votes"
DanCundy-7289 answered DanCundy-7289 edited

Hi @MikeUrnun

After following the documentation at the error management page below and adding the error policy sample into the <on-error> section

api-management-error-handling-policies

I'm still getting my 401 Reponses masked with a 500. Does that sounds like correct behaviour?





5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.