Official Content
  • This documentation is valid for:

Suppose that you need to consume the following REST web service in your GeneXus application:

http://labs.genexus.com/mobilecrm/rest/WorkWithDevicesCompany_Company_List_Grid?fmt=json

where its response is in JSON format and looks as follows:

[{"CompanyId":"1","CompanyLogo":"PublicTempStorage\/image\/gx_upl_a7473480b990012f68a412313d236401.tmp","CompanyName":"Adobe"},

{"CompanyId":"14","CompanyLogo":"PublicTempStorage\/image\/gx_upl_f38b1930f3ff012fc28e12313d236401.tmp","CompanyName":"Apple"}]

To consume it in GeneXus:

1. Define a Structured Data Type object as follows:

SDTCompany

2. Write the following code in your GeneXus object (use HttpClient data type):

&httpclient.Host = "labs.genexus.com"
&httpclient.BaseUrl = "/mobilecrm/rest/"
&httpclient.Execute('GET','WorkWithDevicesCompany_Company_List_Grid?fmt=json')
&companies.FromJson(&httpclient.ToString() )

Where:

&htttpclient is a HttpClient data type variable and

&companies is a collection variable based on the Structured Data Type defined previously.

3. Finished! You already have your companies loaded in your &companies variable

See Also

Rest web services in GeneXus

Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant