Procedures as REST: Using SDT as input to the procedure

Unofficial Content

In a real-life situation, you will probably need to provide feedback about the operation to the user, so you can use a Business Component to perform actions in the database tables and return the operation results to the caller consumer.

In the example, "AddCustomer" Procedure is declared as REST web service in GeneXus.

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


It receives an SDT as parameter, containing the information of the customer to be added to the Customer table.
Also, it returns the error and warning messages in the variable &messages, in order to be able to provide feedback about the operation to the user.

IMPORTANT NOTE: Rest procedures can receive any type of parameters: simple or SDTs, collections or not.

Parm Rule:




if &Customer.Fail()
 &Customer = new()
 &Customer.CustomerId = &Customersdt.CustomerId

&Customer.CustomerName = &Customersdt.CustomerName
&Customer.CustomerBirthDate = &Customersdt.CustomerBirthDate
&Customer.CustomerPayDate = &Customersdt.CustomerPayDate
&customer.CustomerPhoto = &customersdt.CustomerPhoto

&messages = &customer.GetMessages()

Variable &Customersdt is based on Customersdt Structured Data Type:


A GeneXus client for this REST procedure would be as follows:

&httpclient.Host = &host
&httpclient.Port = &port
&httpclient.BaseUrl = &baseurl

&body = '{"Customersdt":' + &customersdt.ToJson() + '}'


Then process the HTTP Client response.


1. The BaseURL for calling REST procedures is <webappname>/rest.
2. Note that the HTTP request is in Json format. Since the procedure receives an SDT (Structured Data Type), the Json expected is preceded by the name of the SDT, which has to be in the same casing as the parameter of the procedure (&Customersdt).
So, the HTTP Request is as follows:


See Also

Rest web services in GeneXus