If you want to expose methods to allow other systems to delete 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 delete data;
  3. Test the method.


We have an application to manage contacts and we want to allow other systems to delete 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 the 'Contacts' REST API, choose 'Add REST API Method', and add the method 'DeleteContact';
  2. Make sure the 'HTTP Method' property is set to 'DELETE';
  3. Add the contact identifier as input parameter, received in the URL;
  4. Implement the logic to delete the contact based on its unique identifier.

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

DELETE /ContactsAPI/rest/Contacts/DeleteContact

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

When calling the DeleteContact method, in the URL of the request you need to send the Id of the Contact record you want to update.

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 DELETE -D- https://osacademy.outsystemscloud.com/ContactsAPI/rest/Contacts/DeleteContact?ContactId=2

The result is a response with status code 200.

See Also

Expose Data Using REST