When using a REST API, you can use your own .NET code to customize the information that is sent in requests or received in responses. For these advanced scenarios, create an extension using Integration Studio and use the REST Extensibility API in your code.
Example use cases:
- Use a specific algorithm to encode part of the request content
- Add support for client-certificate authentication
- Handle a complex response, or customize it according to your needs
Do the following:
In Integration Studio, create an extension to map the .NET code into Service Studio actions. Define actions and their input/output parameters.
Click Edit Source Code .NET in the toolbar to open the extension solution in Microsoft Visual Studio. Use the REST Extensibility API in your .NET code to obtain and manipulate requests/responses.
To see examples of how to use the REST Extensibility API, search for modules that use REST APIs in the Components category of OutSystems Forge.
To learn more about Integration Studio check Extend Logic with Your Own Code.
In Service Studio, add a dependency on the extension actions you will use by opening the Manage Dependencies dialog.
In the REST API, use the following properties:
On Before Request property: set to
New OnBeforeRequest (Advanced)to create a "OnBeforeRequestAdvanced" callback under the REST API tree element. Use it to customize the request before it is sent.
On After Response property: set to
New OnAfterResponse (Advanced)to create a "OnAfterResponseAdvanced" callback under the REST API tree element. Use it to customize the response after it has arrived.
After setting the value, you will have an action named "OnBeforeRequestAdvanced" or "OnAfterResponseAdvanced" under the REST API.
Double-click the newly created action to edit it.
Use the referenced extension actions in the action flow to customize the request or response.