Skip to main content

Extensibility and Integration

 

OutSystems

Simple Customizations

When using a REST API, you can add logic to customize the information that is sent in the requests or received in the responses. For this, the following callbacks are available:

OnBeforeRequest

Use to modify the information of the original request, such as the URL, the request text or the headers.

OnAfterResponse

Use to modify the information of the original response, such as the status code or the response text.

In these callbacks you can access the information from the original request or response, manipulate it and assign a modified value to the customized request or response.

An example of this kind of customization is when you are consuming a REST API that uses token-based authentication and you need to add the token to the URL before sending the request. In this situation you should use the OnBeforeRequest:

REST-simple-customizations-1.png

To customize the request before it is sent:

  1. Set the On Before Request property of the REST API to OnBeforeRequest action. An action with the same name is made available under the REST API;

    REST-simple-customizations-2.png

  2. Double-click the newly created OnBeforeRequest action to edit it;

  3. Add your own logic to customize the request.

To customize the response after it has arrived:

  1. Set the On After Response property of the REST API to OnAfterResponse action. An action with the same name is made available under the REST API;
  2. Double-click the newly created OnAfterResponse action to edit it;
  3. Add your own logic to customize the response.

In the OutSystems Forge you can find several components providing an interface to third-party services using REST integration, such as the Box Connector or the JIRA Connector, where you can see in detail how the REST requests and responses are customized.

  • Was this article helpful?