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:
How do I call the Rest service in GeneXus?
Use the HttpClient data type.
What are the HTTP methods to delete data?
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.
Consider the following example, where we want to delete an Invoice record (which is a two-level transaction). Note that the BC is exposed as a Rest Service.
Here we are going to delete the Invoice whose InvoiceId=1.
&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 service URI 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
With respect to consuming a Rest service (it can be generated by GeneXus or not), GeneXus provides the OpenAPI import tool.