If you want to expose methods to allow other systems to create records in your database, you can do it using a REST API.

Typically, the steps you take are the following:

  1. Create the REST API service, if it doesn't already exist;
  2. Create the REST API method and design the logic to create data;
  3. Test the method.


We have an application to manage contacts and we want to allow other systems to create new  contacts. We will expose a REST API method that implements this.

1. Create the REST API service, if it doesn't already exist

This example is a continuation of the example in the previous topic, and we will add the new method to the existing REST API service.

In case you need to create a REST API service, please read Expose Data using REST.

2. Create the REST API Method and Design the Logic

To create the REST API method proceed as follows:

  1. Right-click on 'Contacts', choose 'Add REST API Method', and add the method 'CreateContact';
  2. Make sure the 'HTTP Method' property is set to 'POST';
  3. Add a contact as an input parameter received in the request body, and the contact id as output parameter;
  4. Design the method as an action that creates a contact, and returns the id of it.

After deploying the application you have access to the following endpoint:

POST /ContactsAPI/rest/Contacts/CreateContact

The HTTP method and the URL is displayed in the properties of the method.

When calling the CreateContact method, in the body of the request you need to send the Contact record you want to create.

Since the input parameter of the method is of Record type, you have to add the 'Content-Type' header to the request, with the value 'application/json'. Learn more about supported media types.

3. Test the Method

We've deployed the application to our environment in the public cloud. To test the method with curl, we use the following command:

curl -H "Content-Type: application/json" -d '{"Name":"Noah Pasquale","JobTitle":"Owner","Phone":"089-0877311"}' -D- https://osacademy.outsystemscloud.com/ContactsAPI/rest/Contacts/CreateContact

The result is a response with status code 200, with the following in the body:

If the record is successfully created, by default the response returns the following values:

See Also

Expose Data Using REST