When you need to retrieve or manipulate information from another system, and that system provides REST APIs for that effect, you can consume a REST API in your application.
Start by looking into the documentation of the REST API you want to use and understand how it works. You will need to gather the following information:
- Base URL
- Security/Authentication requirements
- Methods definition (HTTP Method, URL Path, response format)
Check how you can Consume one or more REST API Methods in Service Studio.
If you want to expose an OutSystems REST API, check Expose REST APIs.
REST API Authentication
Each consumed REST API will have their own model of security and authentication process, which may imply the creation of an account, the registration for an API key or the usage of tokens. To consume a REST API in OutSystems you must understand and follow the provider's security model.
REST APIs using Basic Authentication are supported out of the box in the "Consume REST API Method" dialog box described below. You can use the REST customization capabilities to add support for other authentication methods:
For token-based authentication, use the "OnBeforeRequest" callback to add the required HTTP authorization header to the outgoing requests. Check Simple Customizations for more information.
For client certificate authentication, use the "OnBeforeRequestAdvanced" callback, together with .NET code in an extension, to customize the outgoing requests. Check the HTTPS Consumer component provided by the OutSystems Community for a possible implementation.
Additionally, check the Advanced Customizations topic for more information on how you can implement advanced use cases.
Articles in this Section
- Consume One or More REST API Methods
- How to consume a REST API or a single API method and use it in your OutSystems applications.
- Change a REST API Method
- How to update the definition of a consumed REST API method when in changes.
- REST API Structures
- Check how OutSystems creates and reuses Structures for consumed REST APIs.
- Configure a Consumed REST API at Runtime
- How to override the Base URL and the Basic Authentication credentials of a consumed REST API for a given environment.
- Simple Customizations
- Add logic to customize the information sent in requests or received in responses of consumed REST APIs.
- Advanced Customizations
- Use your own .NET code to customize the information that is sent in requests or received in responses of consumed REST APIs.
- Handling REST Errors
- How to handle error responses returned by consumed REST APIs.
- Unsupported REST Enum Use Cases
- Check the list of currently unsupported use cases when consuming REST services using "enums" and how to overcome some of these situations.