This document explains how to call a Data Provider (DP) exposed as Rest web services in GeneXus.
First, let's see the basic guidelines:
Use the HttpClient data type.
The HTTP method used for calling the Data Provider is the HTTP GET verb.
Are the parameters of the DP. The parameters should be separated by &.
Consider the Invoice Business Component transaction, which looks as follows:
A DP (called "DPCaso20") has been created, whose Data Provider Output is the Invoice BC. Also, it's exposed as a Rest service as shown below:
The DP has the following rule:
The following code is used to call that Rest DP:
&httpclient.Port = 8080
&httpclient.BaseUrl = "BaseUrl"
&httpclient.secure = 0
if &httpclient.StatusCode = 200
&result = &httpclient.ToString()
msg("Error: " + &httpclient.StatusCode.ToString())
Download the sample from Sample consuming a Rest DP
- If the service URI is http://localhost/TestRESTFullGX.NetEnvironment/rest/Invoice, the BASE URL is: /TestRESTFullGX.NetEnvironment/rest/
Java, the parameter name must be normalized (First Character must be uppercase, and all the others must be lowercase) , in this example: Invoicedate, Customerid and Customername.
- Error handling is managed by querying the HTTP Status Code after the invocation.
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.