1
votes

We have configured APIM and point it to API endpoints which is deployed in WebApp.

We have configured products, subscription keys, APIS, Operations for the same.

For APIM endpoints, it is necessary for developer to pass subscription key, if not passed, APIM will return HTTP 401 with below error message

Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription.

Is there any way, we can change this with custom message as required by business team?

2

2 Answers

0
votes

Use choose policy inside on-error section to identify the scenario (you can inspect context.LastError.Reason), and return-response policy to provide custom response.

0
votes

There is currently no way to do this. Please vote for this request on Azure's feedback forum:

Customize error schema messages

Edit: @Vitaliy Kurokhtin answer is a work-around, although you need to keep in mind where you define the error policy (All APIs level, API level, Operation level) will impact whether or not the On Error policy you defined will get invoked