I have created a RESTful API in APIGateway which invokes a different service hosted in a separate webMethods EAI box.
Now when the service returns success, my API returns the payload correctly. But when it returns failure with HTTP codes 500 (say) although the response body is coming good with errorcode and error descr from the native service, the REST API is not able to forward the same.
Instead it gives a generic failure message:
Mediator encountered an error: Native service provider error. Code : 500 while executing operation
which is not explanatory to the caller system.
How to get the correct error code and error descr from the native service via API Gateway? Please suggest.
You need to add an error handling policy to your API. By default the API Gateway masks the native error response by with default message that you are seeing for security reasons.
@John_Carter4 In case of non success code from the native service(other than 2xx series response codes), i see that the response processing phase policies aren’t executed. Is there a way to overcome this. What if i want to transform the payload in case of an error from the native system? What is the correct place to do so? Additionally, is it guaranteed that the response processing policies are only executed in case of 2xx series response code from the native system.
As indicated by @srikanth.prathipati, you need to do error response mapping in the error response policy. You can see it in my screenshot above. You can invoke a service to transform the error response from there.
regards,
John.