Skip to main content

Extensibility and Integration

 

OutSystems

Handling REST Errors

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

To handle a REST API error, do the following:

  1. Add an Exception Handler in the logic that uses the REST API method, and set the Exception Handler to catch All Exceptions;
  2. Implement the logic to handle the error, like displaying a message to the end-user.

REST-handle-errors-1.png

Processing the Response

For situations that require a higher degree of control over the REST API method response, OutSystems allows you to access the original HTTP response, analyze the original values sent by the REST service, such as the status code or the headers, and manipulate them to your needs. You can achieve this doing one of the following:

REST-handle-errors-2.png

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

  • Was this article helpful?