This document explains how to delete data using a Business Component exposed as Rest web services in GeneXus.
First, let's see the basic guidelines:
Use the HttpClient data type.
Delete the data using the HTTP DELETE verb. The PK values have to be added to the query string when the HTTP DELETE verb is executed.
Suppose you want to delete an Invoice record (which is a two-level transaction). Note that the BC is exposed as a Rest Service.
Here, the Invoice whose InvoiceId=1 will be deleted.
&httpclient.Port = &port
&httpclient.BaseUrl = &urlbase
if &httpclient.StatusCode = 200
&result = &httpclient.ToString()
msg("There was an error deleting the data: " + &httpclient.StatusCode.ToString())
Download the sample from Sample Delete Rest BC
- If more than one parameter should be passed in the URL (a compound PK), they need to be separated by commas.
- If the URI service is http://localhost/TestRESTFullGX.NetEnvironment/rest/Product, the BASE URL is: /TestRESTFullGX.NetEnvironment/rest/
- Error handling is managed by querying the HTTP Status Code after the invocation.
Business Components as Rest web services in GeneXus
: GeneXus provides the OpenAPI import tool
for consuming a Rest service, whether it's been generated by GeneXus or not.