Is it possible to customize this error message and have something else instead of this one coming from apigee:
{“fault”:{“faultstring”:“Failed to resolve API Key variable request.queryparam.apikey”,“detail”:{“errorcode”:“steps.oauth.v2.FailedToResolveAPIKey”}}}
Cheers !
Hi @Sebastian Harko
Yes, you do that using Fault handling. You need to add FaultRules section in your API proxy configuration as described here When you encounter an error/exception all the policies under FaultRules will get executed. Based on the error, conditionally you could customize the message and send the error response back using RaiseFault policy.
Eg -
<RaiseFault name="fault_invalidkey">
<FaultResponse>
<Set>
<Payload contentType="text/plain"> {request.header.username} have attempted to access a resource without the correct authorization.
Contact support at support@mycompany.com.</Payload>
<StatusCode>401</StatusCode>
<ReasonPhrase>Unauthorized</ReasonPhrase>
</Set>
</FaultResponse>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</RaiseFault>