Invoke REST API

Invoke REST API asynchronous activity invokes RESTful web services and receives responses from the service provider.

General

Note: For the Invoke REST API activity to work, an HTTP Client shared resource is required. In the HTTP Client shared resource, make sure Apache HttpComponents (Supported by HTTP and REST) is selected as the Implementation Library in the HTTP Client section.

The General tab has the following fields.

Field Module Property Description
Name No The name to be displayed as the label for the activity in the process.
HTTP Client Yes The HTTP client resource.
Resource Path No The resource of the REST service.
Note: Spaces and special characters are not supported in the path and query parameter name.
This field is mandatory.
HTTP Method No The REST methods used for the requests.

Select from one of the following available methods:

  • POST
  • GET
  • PUT
  • DELETE
  • PATCH
Request Type No The value of the Content-Type header set while invoking the REST operation.
  • JSON: the service provider returns the data in the JSON format.
  • XML: the service provider returns the data in the XML format.
  • Custom: to override the Content-Type value in the Input tab, select CUSTOM and provide the value in the Input tab.
Response Type No The value of the Accept header set while invoking the REST Operation.
  • JSON: the service provider returns the data in the JSON format.
  • XML: the service provider returns the data in the XML format.
  • Custom: to override the Accept header value in the Input tab, select CUSTOM and provide the value in the Input tab.

Description

Provide a short description for the activity.

Advanced

The Advanced tab has the following fields.

Field Description
Output HTTP Response Headers Selecting this check box displays the HTTP headers received in the response.
Request Entity Processing This field has two values:
  • BUFFERED: the request entity is buffered in memory to determine the content length that is sent as a Content-Length header in the request.
  • CHUNKED: the entity is sent as chunked encoded (no Content-Length is specified, entity is streamed). The Transfer-Encoding header is set to Chunked.

The default value is Chunked.

Activity Timeout (seconds) Timeout to invoke a RESTful web service and receive a response from the service provider after an Invoke REST API call is sent.

The Default Timeout is three (3) minutes.

Input

The following is the input for the activity.

Input Item Datatype Description
Message Body The body of the HTTP request message.
asciiContent string The ASCII content (ASCII content of the request like POST or PUT to the server) of the request to the HTTP server.
HttpHeaders string The header of the HTTP request. The header structure is defined by the HTTP protocol.
For more information about the fields and content of the header of an HTTP request, see the W3C HTTP specification at w3.org.
  • Accept: specifies the media types that are acceptable for response messages for the incoming request. For example, text/*,text/html.

    For more information about media types, see the W3C HTTP specification at w3.org

    Note: To get status messages for exceptions, set the Accept field to */* or text/html.
  • Accept-Charset: specifies the character sets that are acceptable for response messages for the incoming request. For example, iso-8859-5, unicode-1-1.

    For more information about character sets, see the W3C HTTP specification at w3.org.

  • Accept-Encoding: specifies the content-coding values that are acceptable for response messages. For example, compress, gzip.
  • Content-Type: the media type of the entity body sent to the receiver.

    For more information about media types, see the W3C HTTP specification at w3.org.

  • Content-Length: indicates the size of the entity body sent to the receiver.
  • Connection: the requestor can specify options desired for this connection. For example, the option close specifies that the requestor would like the connection to be closed when the request is complete.
  • Cookie: For more information about this field, see the W3C HTTP specification at w3.org.
    Note: For correct parsing and processing of cookies, input must be in the format "key=value".
  • Pragma: is used to include implementation-specific directives that might apply to the receiver.

    For more information about this field, see the W3C HTTP specification at w3.org.

DynamicHeaders complex The dynamic header is an additional header parameter to add runtime headers to the outgoing HTTP messages. The DynamicHeaders consists of the following information:
  • Name: the name of the header
  • Value: the value of the header

Output

The Output tab has the following fields.

Output Item Description
statusCode The HTTP Response Code.
reasonPhrase ReasonPhrase is intended for giving a short textual description of statusCode.
MessageBody The body of the response message. This is asciiContent.

Fault

The Fault tab lists the possible exceptions generated by this activity. For more information about error codes and the corrective action to take, see the TIBCO BusinessWorks™ Container Edition Error Codes guide.

Fault Generated When..
HttpCommunicationException An HTTP exception occurred when trying to execute the specified method, or when trying to read the response.
HttpClientException The HTTP server replied with a message that has the 4XX status code.
HttpServerException The HTTP server replied with a message that has the 5XX status code.

Support for Path and Query Parameters

Invoke REST API activity supports both Path and Query parameters. For Path Parameters, enclose each path parameter in { } brackets. For example, if the resource path is set as /books/{isbn}, a PathParameters element is added to the activity input.



Multiple path parameters can be defined in a similar way. The activity also supports static URL content mixed with path parameters, for example, /books/{isbn}/events/{author}.

Query parameters are defined using the pattern /staticUrl?Param1&Param2.

A QueryParameters element is added to the Input tab of the activity with each of the parameter listed. For example, if the resource path is set as /books?isbn&author, a QueryParamters element is added to the activity input.



Policy

Activities that support policies display the Policy tab. To associate a new or existing policy with the Invoke REST API activity, click the Add Policy to Activity icon. To edit policy details, click Go to selected Policy icon. The Policy tab has the following fields.

Field Description
Name The name of the policy.
Type The type of policy associated with the activity. The Invoke REST API activity can support the Basic Credential Mapping policy.
Description A description of the policy.