If you want to expose your database to other systems to update records in it, 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 update data;
  3. Test the method.


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

1. Create the REST API service

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 'UpdateContact';
  2. Make sure the 'HTTP Method' property is set to 'PUT';
  3. Add a contact as an input parameter, received in the request body;
  4. Design the method as an action that updates the contact received in the input parameter.

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

PUT /ContactsAPI/rest/Contacts/UpdateContact

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

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

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 -X PUT -H "Content-Type: application/json" -d '{"Id":"187","Name":"Noah Pasquale","JobTitle":"Marketing Manager","Phone":"089-0877311"}' -D- https://osacademy.outsystemscloud.com/ContactsAPI/rest/Contacts/UpdateContact

The result is a response with status code 200.

See Also

Allow Creating Data Using REST