OutSystems Platform provides actions in your application to implement and expose methods of REST APIs. Methods can be organized under multiple REST APIs. See how to expose REST APIs in expose data using REST.

Read also more about supported media types in REST API requests and built-in HTTP status codes.

REST API Method Lifecycle

When a request is received to execute a REST API method, this is the flow:

  1. Security Validations: after receiving a request, security validations are executed according to what is configured in the 'HTTP Security' and 'Internal Access Only' REST API properties;
  2. OnRequest(): a callback for you to run logic over requests, after receiving them;
  3. OnAuthentication(): a callback for you to add custom authentication to requests;
  4. Parameters Deserialization and Validation: deserializes input parameters and validates data types, mandatory values, etc.;
  5. Execute Method: executes the action that implements the REST API method;
  6. Parameters Serialization: serializes output parameters to return in the response;
  7. OnResponse(): a callback for you to run logic over responses, before sending them. It is always executed, even in case of error.

Properties

Property

Description

Optionality

Default value

Obs.

Name

Name that identifies the method in the module.

Mandatory

 

 

Description

Text that describes the method.

Optional

 

 

URL Path

Allows customizing the URL of the method in order to follow RESTful principles identified by your organization.

Mandatory

The /<method_name> in the URL property.

Due to a limitation in .NET stack, it cannot end with a '.' sign, otherwise method calls won't work.

 

Learn how to customize REST URLs.

URL

The relative URL where the method is available.

Mandatory

/<module_name>/rest/<REST_API_name>/<method_name>

Read-only

HTTP Method

The HTTP verb required to call the method.

Mandatory

GET

 

How Does the URL Path Work

By default, OutSystems Platform builds endpoints using the HTTP verb (GET, POST, PUT, DELETE) and the name of the REST API method.

For example:

Default Endpoint

Description

GET https://<server>/Contacts/rest/ContactsAPI/GetContacts

Gets all contacts

GET https://<server>/Contacts/rest/ContactsAPI/GetContact

Gets a contact

POST https://<server>/Contacts/rest/ContactsAPI/CreateContact

Creates a contact

PUT https://<server>/Contacts/rest/ContactsAPI/UpdateContact

Updates a contact

DELETE https://<server>/Contacts/rest/ContactsAPI/DeleteContact

Deletes a contact

GET https://<server>/Contacts/rest/ContactsAPI/GetContactAddresses

Get all addresses of a contact

To customize endpoints to your needs, use property 'URL Path'.

The following sections describe some techniques of how to customize endpoints.

Endpoints for Collections

Use the same name for methods related with a resource. OutSystems Platform knows which method to execute through the HTTP verb.

Default Endpoint

URL Path

Customized Endpoint

GET https://.../GetContacts

/Contacts

GET https://.../Contacts

POST https://.../CreateContact

/Contacts

POST https://.../Contacts

Endpoints for a Resource

When handling a specific resource, start the URL Path with the collection name and, depending on the HTTP verb, add the following:

GET or DELETE: add the resource identifier (the input parameter of the REST API method) between '{' and '}';

PUT: add nothing, because the resource is already passed in the request Header or Body.

Default Endpoint

URL Path

Customized Endpoint

GET https://.../GetContact

/Contacts/{ContactId}

GET https://.../Contacts/{ContactId}

DELETE https://.../DeleteContact

/Contacts/{ContactId}

DELETE https://.../Contacts/{ContactId}

PUT https://.../UpdateContact

/Contacts

PUT https://.../Contacts

Endpoints for Sub-collections

With master-detail relationships, handle details as a collection under the master resource.

Default Endpoint

URL Path

Customized Endpoint

GET https://.../GetContactAddresses

/Contacts/{ContactId}/Addresses

GET https://.../Contacts/{ContactId}/Addresses

Combine these techniques to further customize your REST URLs.

See Also

Expose Data Using REST | Exposed REST API Properties