REST stage in DataStage

The REST stage makes calls to APIs to retrieve data, send data, and perform other operations through RESTful endpoints.

The REST stage supports one input link and multiple output links, including a reject link. With the REST stage, you can retrieve paginated data, chain requests together, and define variables to reuse values. The REST stage has three tabs:

  • The Stage tab handles requests. Specify details for authentication, request body, saving the response, security, and pagination. You can also define variables to keep track of information such as the number of iterations. For more information, see Rest stage: Stage tab (DataStage).
  • The Input tab is where you define your input data.
  • The Output tab is where you define your output data.

Several examples are provided to help you quickly build and configure your API calls. To use one, click Import example in the header of the stage editor and select an example. After import, set variable values and add output columns as needed to handle the data for your specific example.

REST stage as a target

In the Input tab you can define your input data. You can specify the column definitions of incoming data. The Advanced section allows you to change the default buffering settings for the input link.

REST stage as a source

In the Output tab you can define your output data. You can specify the column definitions of outgoing data. You must provide a derivation for each column. Specify JSON.toJson(RESPONSE_BODY) to pass a JSON string to a stage downstream. To pass a column's data directly to a stage downstream, specify the column as the derivation with format <link_name>.<column_name>. To add a reject link, add a primary link, select Is reject link, and select a column for reject messages. You can also choose the Runtime column propagation option.

The Advanced section allows you to change the default buffering settings for the output link.

REST stage as a transformer

The REST stage can have upstream and downstream stages. The REST stage gets input from upstream stage to build a REST call request and writes the data to downstream stages.

Parametrization of REST stage

You can add parameters to REST stage in DataStage®.

Table 1. Endpoint methods
Endpoint
HTTP method
GET
Retrieves the information in the form of an entity that is identified by the request Uniform Resource Identifier (URI) of the request body.
POST
Requests that the origin server accept the data that is enclosed in the body of the request message. This method is often used to upload resource data.
PUT
Requests that the enclosed entity be stored under the request URI that is specified.
DELETE
Requests that the origin server delete the resource that is identified by the request URI.
OPTIONS
Displays a list of HTTP methods that are supported by the server for the specified URI.
HEAD
Retrieves only the header information in the response. This method is often used to verify that hypertext links are valid and identify whether the links changed.
PATCH
Changes existing resources. You can use the PATCH method to update a single field of the resource.
URL

URL supports constant string and expression. If use expression, the last statement returns the real URL string value by evaluator.

Table 2. Authentication methods
Authentication
API Key

Use API keys for authentication when the API provider requires it. Input the key as a string in the relevant field.

Basic Authentication

Use your username and password when making an authentication request.

Bearer Token

Bearer tokens are commonly used for API authentication. Provide the token as a string in the designated field.

Digest Authentication

Use your username and password when making an authentication request. This authentication method applies a hash function to the username and password before sending them over the network.