Creating and retrieving data by invoking REST Web service - Cloud - 8.0

REST

Version
Cloud
8.0
Language
English
Product
Talend Big Data
Talend Big Data Platform
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Real-Time Big Data Platform
Module
Talend Studio
Content
Data Governance > Third-party systems > Internet components (Integration) > Web protocols > REST components
Data Quality and Preparation > Third-party systems > Internet components (Integration) > Web protocols > REST components
Design and Development > Third-party systems > Internet components (Integration) > Web protocols > REST components
Last publication date
2024-02-20

This scenario describes a simple Job that invokes a REST Web service to create a new customer record on the server end and then retrieve the customer information. When executed, the Job displays relevant information on the Run console.

For more technologies supported by Talend, see Talend components.

  • Drop the following components from the Palette onto the design workspace: two tREST components and two tLogRow components, and label the two tREST components to best describe the actions to perform.

  • Connect each tREST to one tLogRow using a Row > Main connection.

  • Connect the first tREST to the second tREST using a Trigger > OnSubjobOK connection.

  • Double-click the first tREST component to open its Basic settings view.

  • Fill the URL field with the URL of the Web service you are going to invoke. Note that the URL provided in this use case is for demonstration purposes only and is not a live address.

  • From the HTTP Method list, select POST to send an HTTP request for creating a new record.

  • Click the plus button to add a line in the HTTP Headers table, and type in the appropriate name-value key pair, which is subject to definition of your service provider, to indicate the media type of the payload to send to the server end. In this use case, type in Content-Type and application/xml. For reference information about Internet media types, visit www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7.

  • Fill the HTTP Body field with the payload to be uploaded to the server end. In this use case, type in <Customer><name>Steven</name></Customer> to create a record for a new customer named Steven.

Note:

If you want to include double quotation marks in your payload, be sure to use a backslash escape character before each of the quotation marks. In this use case, for example, type in <Customer><name>\"Steven\"</name></Customer> if you want to enclose the name Steven in a pair of double quotation marks.

  • Double-click the second tREST component to open its Basic settings view.

  • Fill the URL field with the same URL.

  • From the HTTP Method list, select GET to send an HTTP request for retrieving the existing records.

  • In the Basic settings view of each tLogRow, select the Print component unique name in front of each output row and Print schema column name in front of each value check boxes for better identification of the output flows.

  • Save your Job and press F6 to launch it.

    The console shows that the first tREST component sends an HTTP request to the server end to create a new customer named Steven, and the second tREST component successfully reads data from the server end, which includes the information of the new customer you just created.