2015-05-04
1.0.0
OutSystems TechComm
9.0.1.3
All
All
How-tos
[Overview]
Sample of an exposed REST API with methods to list, create, update, and delete records. It also demonstrates how to send a custom error message if something goes wrong in the execution of the requested method. The REST API uses Basic authentication.
[Detail]
REST APIs allow you to expose data and functionality of your application over HTTP to be used by other systems.
Each REST API method of this project illustrates one or two use cases of how you can use expose REST APIs. Check how to:
Expose a method to provide data
- In the method, set the 'HTTP method' property to GET;
- Add a Contact List as output parameter;
- Set the placement of the output in the request at the 'Send In' property of the parameter.
Learn more about how to expose data using REST.
Expose a method to create data
- In the method, set the 'HTTP Method' property to POST;
- Add a Contact as input parameter, and a Contact Identifier as output parameter;
- Set where the input parameter is received in its 'Receive In' property;
- Set where the output parameter is sent in its 'Send In' property.
Learn more about how to expose a method to create data using REST.
Expose a method to update data
- In the method, set the 'HTTP method' property to PUT;
- Add a Contact as input parameter;
- Set the placement of the input in the request at the 'Receive In' property of the parameter.
Learn more about how to expose a method to update data using REST.
Expose a method to delete data or raise an error
- In the method, set the 'HTTP method' property to DELETE;
- Add a Contact Identifier as input parameter;
- Set the placement of the input in the request at the 'Receive In' property of the parameter;
- In the method logic, raise a custom error using the Raise Error element if there is any problem with deleting this record.
Learn more about how to expose a method to delete data using REST.
Learn more about how to add a custom error message.
Add Basic authentication to an exposed REST API
The action calls the User_Login action of the Users module.
If the authentication succeeds, the invoked REST API method is executed immediately after.
Otherwise, an exception is raised, the request is aborted, and the response returns a security error.
Learn more about how to add Basic authentication to an exposed REST API.