Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 5 REST and JSON Palette : Invoke REST API

Invoke REST API
Activity
The Invoke REST API activity calls RESTful web services and receives responses from the service provider.
Configuration
The fields on the Configuration tab are described in Table 10.
TIBCO ActiveMatrix BusinessWorksTM Plug-in for REST and JSON supports the following types of protocols:
Note: This field is available only when the protocol type is None.
Note: If the protocol type is WADL or Swagger, only the methods that correspond to the API are listed in the Method field.
Note: This field only appears when you select WADL as the protocol type.
Note: This field only appears when you select Swagger as the protocol type. This activity supports Swagger 1.2 and 2.0 specifications.
See OAuth1.0 for more information about the OAuth1.0 shared resource.
Header  Send the access token in an HTTP header.
Query  Include the access token as a URL query parameter.
Reload Button
If the WADL or Swagger file is changed, you must use the Reload button to refresh the WADL or Swagger file to update the Configuration and Input tabs.
Sending Data in the HTTP request
The Invoke REST API activity contains different types of parameters for sending data in a request:
Describing RESTful Web Service with WADL or Swagger Files
If the protocol type is WADL or Swagger, and a WADL file or Swagger file is given, the WADL file or Swagger file is mapped to the input parameters in the Input tab.
You cannot alter the structure of the HTTP request message in the Input tab. If the data structure in the WADL file or Swagger file does not match the RESTful web service, edit the elements in the file and click Reload.
Table 11 shows the rules for mapping a WADL file to the input parameters.
In a WADL file, if the style attribute value is template, the name of the parameter is mapped to the Template parameter in the Input tab.
Note: During runtime, the parameters can be replaced with the input values in the Input tab.
  <param name="format" required="true"    type="xsd:string" style="template"    default="json">
In this example, the format parameter is mapped to the input parameter.
In a WADL file, if the style attribute value is query, two parts in a WADL file are mapped to the Query parameter:
The param node directly under the resource tag: In this case, the Query parameter is shared by all the method nodes under this resource tag.
The param node under the request tag: In this case, the Query parameter is only applicable for this method.
The following example shows the param node directly under the resource tag in a WADL file:
The following example shows the param node under the request tag in a WADL file:
      <param name="param1"        required="true"        type="xsd:string" style="query"        default="12345">
In a WADL file, if the style attribute value is header, the name of the parameter is mapped to the Header parameter.
The XML nodes under the representation tag are mapped to the Body parameters.
In a WADL file, if the style attribute value is Query and the nodes are under the representation tag, the name of the parameter is mapped to the Form parameter, and is encoded in application/x-www-form-urlencoded.
  <representation>
Table 12 shows the rules for mapping a Swagger file to the input parameters.
In a Swagger file v1.2, if the paramType parameter value is path, the name of the parameter is mapped to the Template parameter in the Input tab.
In a Swagger file v2.0, the paramType parameter is renamed to in.
   "name": "petId",
   "description": "Pet id to delete",
   "required": true,
   "type": "string",
   "paramType": "path",
   "allowMultiple": false
   "name": "petId",
   "in": "path",
   "description": "Pet id to delete",
   "required": true,
   "type": "integer",
   "format": "int64"
In this example, the path parameter is mapped to the Template input parameter.
In a Swagger file v1.2, if the paramType parameter value is query, the name of the parameter is mapped to the Query parameter in the Input tab.
In a Swagger file v2.0, the paramType parameter is renamed to in.
   "paramType": "query"
   "in": "query",
In this example, the query parameter is mapped to the input parameter.
In a Swagger file v1.2, if the paramType parameter value is header, the name of the parameter is mapped to the Header parameter in the Input tab.
In a Swagger file v2.0, the paramType parameter is renamed to in.
   "paramType": "header",
   "in": "header",
In this example, the header parameter is mapped to the input parameter.
In a Swagger file v1.2, if the paramType parameter value is form, the name of the parameter is mapped to the Form parameter in the Input tab.
In a Swagger file v2.0, the paramType parameter is renamed to in.
   "paramType": "form"
In this example, the form parameter is mapped to the input parameter.
   "in": "formData",
In this example, the formData parameter is mapped to the input parameter.
Describing RESTful Web Service Without WADL or Swagger Files
The description for the input parameters are shown in Table 13 for when the Protocol type is None.
You cannot alter the structure of the HTTP request message in the Input Editor tab. However, you can alter the child items under the three main parameters: Query, Header and body (including Form, Text, Binary, and Multipart). For example, add another param item under the Query parameter.
Specifies a URI query parameter for all methods that apply to the URI resource. The Query parameter is appended to the URL and is encoded in application/x-www-form-urlencoded.
type  This field must be defined according to content type encoding required by request. For example,
content  The content of the data for HTTP request.
type  In this field, specify the file name of the HTTP message attachment. TIBCO ActiveMatrix BusinessWorksTM Plug-in for REST and JSON converts the file name to the MIME type automatically.
content  The content of the HTTP message attachment.
Note: If type and content parameters are not specified, the Binary parameter is ignored.
Note: If the Service Provider requires the multipart/mixed encoding, add a header x with the name Content-Type and set the value of this parameter to multipart/mixed.
Input Editor
The Input Editor tab describes the data structure for the HTTP request message in the Input tab. If the Protocol type is WADL or Swagger, you can alter the element structure under the these parameters: Query, Header, and Body. See Table 13 for more details about each parameter.
For each element you add, you must provide a name, data type, and the parameter details such as required, optional, or repeating.
For more information about how to use the Input Editor tab, see "Specifying Data Schema" in TIBCO ActiveMatrix BusinessWorksTM Palette Reference.
Input
The Input tab contains the following fields as shown in Table 14.
The root and the path of a URI resource. The URI resource is set in the Resource URI field in the Configuration tab, but you can override the value by specifying the URI resource in this field.
The items displayed under the Parameters item vary depending on whether the Enable WADL check box in the Configuration tab is selected. See Sending Data in the HTTP request for detailed information about the items.
The name of the access token provided by the authorization server’s token endpoint. The access token name is set in the Token Name field in the Configuration tab, but you can override the value by specifying an access token name in this field.
The value of the access token provided by the authorization server’s token endpoint. The access token value is set in the Token Value field in the Configuration tab, but you can override the value by specifying an access token value in this field.
A valid user name for accessing a website. The user name is set in the Username field in the Configuration tab, but you can override the value by specifying a user name in this field.
A valid password for accessing a website. The password is set in the Password field in the Configuration tab, but you can override the default by specifying a password in this field.
Output Editor
The Output Editor tab describes the data structure in the Output tab. It allows you to add headers and set the response data type.
For each element you add or edit, you must provide a name, data type, and whether the parameter is required, optional, or repeating.
This tab is available only when the Rich Output check box is selected in the Configuration tab. When the Rich Output option is enabled, the output varies depending on the schema type defined in the Output Editor tab.
For more information about how to use the Output Editor tab, see "Specifying Data Schema" in TIBCO ActiveMatrix BusinessWorksTM Palette Reference.
Output
The Output tab contains the following fields as shown in Table 15.
The following fields appear when you select the Rich Output check box in the Configuration tab .
Error Output
The Error Output tab lists the exceptions that can be generated by the Invoke REST API activity. See Trace Messages for more information about error codes.

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved