When retrieving data from a REST API, if the service returns an HTTP error status code (400 and above), the OutSystems Platform throws an exception. This allows you to easily handle the REST API error by implementing your own logic.

Handling the Error

To handle the error, add an Error Handler in the logic that uses the REST API, and set the error handler to catch All Exceptions. Then implement the logic to handle the error, like displaying a message to the end-user.

Processing the Response

For situations that require an higher degree of control over the REST method response, the OutSystems Platform allows you to have access to the raw HTTP response. This way you can analyze the HTTP headers and body of the response sent by the REST service, and manipulate them to your needs.

For this, the following actions are available:

Since these actions run before the OutSystems Platform processes the REST response, if you change the status code of the response to success (200), the OutSystems Platform no longer raises an exception.

See Also

Troubleshooting REST APIs| OnAfterResponse | OnAfterResponseAdvanced