Serves as a REST Web service client.
The tREST component sends HTTP
requests to a REpresentational State Transfer (REST) Web service
provider and gets responses correspondingly.
tREST Standard properties
tREST component belongs to the Internet family.
To build Jobs that need to be deployed into the Talend Runtime, it is
recommended to use the tRESTClient component which is best
suited for the Talend Runtime.
For more information about the tRESTClient component, see tRESTClient.
The component in this framework is available in all Talend
Schema and Edit
A schema is a row description, it defines the number of fields
This component always uses a built-in, read-only schema that
– Body: stores the result from
– ERROR_CODE: stores the HTTP
Click Edit Schema to view the
Changing the schema type may result in loss of the
Type in the URL address of the REST Web server to be invoked.
From this list, select an HTTP method that describes the desired
– GET: retrieves data from the
– POST: creates and uploads data
– PUT: updates data based on the
– DELETE: removes data based on the
Type in the name-value pair(s) for HTTP headers to define the
For the specific definitions of HTTP headers, consult your REST
Type in the payload to be uploaded to the server end when the
Select this check box to gather the Job processing metadata at the
ERROR_MESSAGE: the error message generated by the
A Flow variable functions during the execution of a component while an After variable
To fill up a field or expression with a variable, press Ctrl +
For further information about variables, see
Use this component as a REST Web service client to communicate
JRE 1.6 must be running for this component to work
Creating and retrieving data by invoking REST Web service
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.
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
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
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
to create a record for a new customer named Steven.
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
if you want to enclose the name Steven in a pair of double
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
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.