HowTo: Consuming a Procedure exposed as a Rest service

Official Content
This documentation is valid for:

The following is a simple example where we consume a procedure exposed as a Rest web service, which only receives simple parameters and doesn't return any.

In the example, the "AddCustomer" Procedure is declared as REST web service in GeneXus, so the following properties are set as described here:

  • Expose as web service = true
  • Rest protocol = true


The procedure receives "in" parameters in order to add a Customer to the corresponding table:

Parm Rule:



   CustomerId = &CustomerId
   CustomerName = &CustomerName
   CustomerBirthDate = &CustomerBirthDate

In order to call AddCustomer as a REST web service, you should use HttpClient data type. A GeneXus client should look as shown below:

// http://server:8080/BaseUrl/rest/AddCustomer
&httpclient.Host = 'server'
&httpclient.Port = 8080
&httpclient.Secure = 0
&httpclient.BaseUrl = 'Baseurl'
&body = &customersdt.ToJson() //&customersdt is a variable of CustomerSdt data type which is an SDT that includes the CustomerId, CustomerName and CustomerBirthDate items.
&body = '{ "Customer":' + &body + '}' 

//Then process the HttpClient response.

Download the sample from Sample consuming a Rest procedure

As shown in the example, the parameters are sent in Json format in the body of the HttpRequest; that's why in the example we use the method to convert the data contained in an SDT to Json format.


With respect to consuming a Rest service (it can be generated by GeneXus or not), GeneXus provides the OpenAPI import tool.


Next, read Procedures as REST: Using SDT as input to the procedure

See Also

Rest web services in GeneXus