Contents

Popular
 Contents

Use Case

The example demonstrates the way errors from target servers can be handled and customized using the rules and Fault Handling policy. Consider a case where the back end API which returns JSON sends an HTML page when the resource is not available. The client JSON parsers could fail to interpret the responses. Using Fault Handling policy, the response can be customized so that a 500 (Internal Server Error) is sent in predefined JSON format.

Policies used in the Use Case

Fault Handling Policy - The error response is customized using this policy.

Creating the Project

Create a project from a REST/HTTP service as defined in Adding API project section.

Steps to perform Error Handling

Adding the Policy

Fault Handling Policy needs to be added as explained in the Adding Policy section.

Assigning Rule

A rule needs to be assigned to the policy so that the policy gets executed on certain conditions. Error codes 404 (Not Found) and 500 (Internal Error) are used in this example. Since these errors are mostly due to issues with the back end APIs and cannot be controlled by API user, appropriate error message is sent to the client reporting the issue.

Customizing the Error

The error is customized so that the 404 HTML page returned by back end server is replaced by a JSON response and HTTP 500 response code which corresponds to internal error at the API Proxy Server. The status code, status phrase and the message to be sent back to the client can be customized as part of the Fault Handling Policy configuration as below.

Adaptavist ThemeBuilder EngineAtlassian Confluence