InvokeRESTService

This Activity is used to request a REST service; it also accepts the reply returned by the service.

The Activity supports two modes of operation. The default mode supports arbitrary REST services. The TIBCO Cloud Mesh mode lets you select any services running in TIBCO Cloud and managed by your organization. For more information on TIBCO Cloud Mesh, see https://account.cloud.tibco.com/cloud/docs/cloud-mesh/index.html.

Settings

Field Description
Discover services from TIBCO Cloud Mesh Discovers services from the TIBCO Cloud Mesh.

Default: False

Browse TIBCO Cloud Mesh Service
Note: This field is displayed only if you are using TIBCO Cloud Mesh.

Name of the service you want to invoke.

A dialog displays all services available in your organization. After selecting a service, select the path and method from the list.

Note: While configuring the Activity with a service from TIBCO Cloud Mesh, you might see a duplicate service name for existing services with multiple endpoints. If you see a duplicate service name, repush the Flogo service app.
API Spec (Optional) Click Browse and browse to the file location on the machine. Select a JSON file.

Supported specifications are Swagger Specification 2.0 and OpenAPI Specification 3.0.

Resource Path
Note: This field is only displayed if you are using TIBCO Cloud Mesh or if you upload a JSON file in the API Spec field.

If you are using TIBCO Cloud Mesh:

This is the resource path for the operation. It is automatically populated after you select a path from the Browse TIBCO Cloud Mesh Service dialog.

This field is non-editable.

If you upload a JSON file in the API Spec field:

All resource paths available in the JSON file (that is, the Swagger 2.0 or OpenAPI 3.0 specification file you uploaded) are listed in the dropdown. Depending on the resource path you select, the supported operations are listed in the Method field.

Enable Authentication

Select True if you want to enable authentication and authorization for your apps using the HTTP Client Authorization Configuration connection.

Default: False

Authentication Connection
Note: This field is displayed only if the Enable Authentication field is set to True.

Select a connection that you have set up from the dropdown list.

For information on setting up a connection, refer to HTTP Client Authorization Configuration.

Method Select an operation for the request. For example: GET, POST, PUT, DELETE, or PATCH.

If you are using TIBCO Cloud Mesh, this field is automatically populated after you select a method from the Browse TIBCO Cloud Mesh Service dialog. This is a non-editable field.

URL
Note: This field is not displayed if you are using TIBCO Cloud Mesh.

An absolute path to the REST service that you want to invoke. For example: http://acme.com or https://acme.com.

Note: If you upload an OpenAPI 3.0 JSON specification file in the API Spec field, the URL is a dropdown list. This lists the server URLs mentioned in the JSON file. Select a server URL from the list.
Tip: To override dynamically the path provided in the URL, you can enter the URL as:
http://<host-url>:port/{path}
Here, {path} is the parameter that can be modified. You can map this parameter in the Input section and assign values to it from the previous activities or the app properties.
Use certificate for verification

This field is displayed if you enter an absolute path beginning with https:// in the URL field. Set this to True to use a certificate for a secure connection to the server.

Default: False

Use mTLS

Set to True to enable mutual authentication for a secure connection to the server.

Default: False

Client Certificate

This field is displayed only if Use mTLS is set to True.

This certificate is used to identify the client by the servers over TLS. The certificate must be PEM encoded. Click Browse and select the client certificate.

Alternatively, you can configure the app property by using the Bind an Application Property toggle. Set the Base64-encoded value of the client certificate to the corresponding app property.

Client Key

This field is displayed only if Use mTLS is set to True.

Click Browse and select the client key. The key file must be PEM encoded.

Alternatively, you can configure the app property by using the Bind an Application Property toggle. Set the Base64-encoded value of the client key to the corresponding app property.

CA/Server Certificate

Click Browse and select a certificate authority (CA) certificate that verified the client's certificate or the server certificate to establish a secure connection during the TLS handshake. The certificate must be PEM encoded.

Alternatively, you can configure the app property by using the Bind an Application Property toggle. Set the Base64-encoded value of the CA/Server certificate to the corresponding app property.

Close Connection Select True if you want to terminate the connection to the server after the response is processed. This affects the performance as the connection is no longer cached.
Default: False
Timeout

Specify the timeout period (in milliseconds) for invoking a service. If a timeout value is specified, the Activity waits for the specified time. If the response is not received by the specified time, the request expires with an error.

Default: 0 milliseconds (that is, there is no timeout for invoking a service)

Request Type
Note: This field is displayed only for the POST, PUT, and PATCH methods.
The Request content type of the REST service. The following content-type are supported:
  • text/plain
  • application/json
  • application/x-www-form-urlencoded
  • multipart/form-data
Note:
  • If you select application/x-www-form-urlencoded, the default schema is set in the Request Schema field of the Input Settings tab. You can edit the default schema or specify your schema. If you specify your schema, it must be a name-value string pair.

  • For the application/x-www-form-urlencoded request type, use the url.queryEscape function to get the expected input at the server.


  • If you select the multipart or form-data as a request type, then you can pass the content-type for the file and files options in the Input.

  • If you do not set the content-type, then the application/octet-stream is set as the default content-type for file and files input.

Proxy

Specify the URL to the HTTP proxy server. If a proxy URL is specified, the request to the REST service (specified in the URL field) is routed via this proxy URL.

Note: A secure connection to the proxy server is not supported.

Default: Proxy URL is disabled.

Input Settings

Note:
  • If you upload a JSON file in the API Spec field, the fields in Input Settings are automatically populated according to the Resource Path you select.
  • If you are using TIBCO Cloud Mesh, you do not need to configure input settings. The input settings are automatically configured to match the selected service, and cannot be changed.

  • The InvokeRESTService supports gzip and deflate encoding.

Field Description
Query Params Query parameters to be appended to the path. To add the query parameters, click and press Enter to save your changes.
  • parameterName: Name of the query parameter.

  • type: The data type of the query parameter. Supported types are string, number, boolean, and object.

    Note: Only a simple JSON object type is supported.
  • required: Set to True if the query parameter is a required configuration. The trigger reports an error if no values are provided to the required query parameter.

Path Params Path parameters that are appended to the path. This is a non-editable field.
  • parameterName: Name of the path parameter. This is the parameter specified in between { } in the Resource Path field or the URL field in Settings.

  • type: The data type of the path parameter. The Supported type is string.

Request Headers Header values for the InvokeRESTService Activity. To add the header parameters, click and press Enter to save your changes.
  • parameterName: Name of the header parameter.

  • type: The data type of the header parameter. Supported types are string, number, and boolean.

  • required: Set to True if the header parameter is a required configuration. The trigger reports an error if no values are provided to the required header parameter.

Request Schema

Enter a request schema here. This field is visible only if you selected the POST, PUT, PATCH, or DELETE method on the Settings tab.

Note:
  • For the DELETE method, specifying the request schema here is supported for manual configuration only and not when configured with Tibco Cloud Mesh and API specification.

  • If you selected application/x-www-form-urlencoded as the Request Type on the Settings tab, the default schema is set here. You can edit the default schema or specify your schema. If you specify your schema, it must be a name-value string pair.

Multipart Data This field is displayed in place of the Request Schema field if you select multipart/form-data as the Request Type on the Settings tab. Click to add the parameters.
  • Name: Name of the parameter.

  • Type: The Supported types are string, object, and filecontent, file, and files.

    • For file types such as images and PDF files, convert your file to Base64 format and enter the encoded value as the Input.

    • To send the file name and the file content in the same request, use file or files types. With file type, you can send one file and file name. With the type files, you can send multiple file content for one file name.

  • Required: Check the box if the parameter is a required configuration.

  • Schema: Enter the JSON schema in this field if the Type is an object.

    Note: If you want to pass dynamic data to multipartFormData field, no data must be defined in MultipartData table. Otherwise, the dynamic data is not honored and only table field values are considered.
Note: If you are using TIBCO Cloud Mesh, serviceAppId parameter is displayed in the Path Params field. This parameter indicates the Cloud Mesh service app ID. App properties can be mapped to this parameter that can be overwritten at runtime.

You can use this parameter for CI/CD implementation. Push the service app to obtain the app ID. You can use the app ID to overwrite the serviceAppId parameter that is configured in the input when TIBCO Cloud Mesh is enabled.

Input

Note: If you upload a JSON file in the API Spec field, the Input fields are automatically populated according to the Resource Path and Method you select.
Field Description
host Specify the value that must override the hostname:port value specified in the URL at runtime with the value specified in this configuration. Enter a value in the form hostname[:port] where [:port] is optional.
queryParams Provide a value to the query parameters configured in the Input Settings section.
pathParams Provide a value to the path parameters defined as part of the URL on the Settings tab.
headers Header values for the Activity. These values can be manually entered or mapped to the output of the trigger or any preceding Activity.
body

Request Schema values for the Activity. These values can be manually entered or mapped to the output of the trigger or any preceding Activity. This field is visible only if you selected the POST, PUT, PATCH, or DELETE method on the Settings tab.

Note: For the DELETE method, specifying the request schema here is supported for manual configuration only and not when configured with Tibco Cloud Mesh and API specification.
multipartFormData This field is visible if you select file or files type in the Multipart Data field on the Input Settings tab.

Each file that you enter in the Multipart Data table is displayed here. content, filename and content-type fields are displayed for each file.

Output Settings

Note: If you are using TIBCO Cloud Mesh, you do not need to configure output settings. The output settings are automatically configured to match the selected service, and cannot be changed.
Note: If you upload a JSON file in the API Spec field, the fields in Output Settings are automatically populated according to the Resource Path you select.
Field Description
Configure Response Codes Use this field to configure response codes.

Default: False (See "Response Schema" and "Response Type" in this table.)

To specify a response code, select True and click . Enter the following details:

  • Code: Enter a specific response code or configure a single schema for a category of response codes. For example, if all the status codes are similar (such as 501, 502, 503), you can define a single schema (as 5xx) for them. Defining a single schema saves you time and effort as you do not need to configure each status code separately in the Activity.
    Note: If the status code is provided as a range (5xx in the above example) and also in an absolute format (501 in the above example), the status code in the absolute format is given priority. In the above example, status code 501 is given priority over 5xx at runtime.
  • Type: Select the type of response expected for the Code. Supported types are String and Object.

  • Response Body: If the Object is selected as the Type, enter the JSON schema in the Response Body column. For String, you need not enter anything in the Response Body column.

  • Response Headers: Specify the response header corresponding to the response code.
  • Actions: The actions displayed change based on the type of the response code.
    • Edit, Delete: For an Object type of response, you can edit the details or cancel it.
    • Save, Cancel: For a String type of response, you can save or cancel the changes.

The response codes are displayed on the Output tab.

Response Schema
Note: This field is displayed only when Configure Response Codes is set to False.
The schema for the reply that the server sends.
Response Type
Note: This field is displayed only when Configure Response Codes is set to False.

The content type of the REST service. The following content types are supported:

  • application/json
  • application/xml
  • text/plain
  • other

Default: application/json

JSON to XML conversion is not supported by the REST Activity. Any service that requires data in XML format cannot be invoked after providing data in the JSON format using REST Activity.

If the content type is other than the types application/json, application/xml, or text/plain, it is converted into Base64 encoded values. You can use the utils.decodeBase64 function to get the actual values. This is applicable when Configure Response Codes is set to True or False.

Output Format
Note: This field is displayed only when the Response Type is set as application/xml.

The format of the requested content for the application/xml response type. The following formats are supported:

  • JSON Object

  • XML String

Response Schema

Sample JSON schema for the response that the REST service returns.

The JSON schema in this field is editable for the following settings only:

  • When the Response Type is set as application/json

  • When the Response Type is set as application/xml and the Output Format is set as JSON Object

Response Headers

The header parameters for the reply.

Tip: If you want to fetch a cookie coming with a response, add a new row with Set-Cookie as the parameter. You can also map this parameter to subsequent activities in the flow.

Output

The Output tab displays the headers and responsebody configured for the response in a tree format. The responseTimeInMilliSec parameter specifies the time taken to receive the response in miliseconds.

Loop

Refer to the section on "Using the Loop Feature in an Activity".

Retry on Error

Refer to the section on "Using the Retry on Error Feature in an Activity".

Note: To update all these settings for an Activity configured from Swagger 2.0 or OpenAPI 3.0 specification, make changes in the API specification file and upload it to Settings. Do not update the Activity settings as manual updates are removed.