invoke
Use the invoke policy to call an API.
The invoke policy does not support responses with multipart form data, that is, when the response is set to Content-Type: multipart/related.
The invoke policy has the following format:
- invoke:
title: title
description: description
target-url: URL_of_target_API
tls-profile: TLS_profile_to_be_used
verb: method_type
timeout: timeout_value_in_seconds
compression: is_data_to_be_compressed
username: username_if_authentication_required
password: password_if_authentication_required
output: location_of_the_invoke_result
cache-key: unique_identifier_of_the_document_cache_entry
cache-response: cache_behavior
cache-putpost-response: response_caching_behavior
cache-ttl: cache_time_to_live
stop-on-error:
- stop_on_error_type- If the HTTP request made by the invoke or proxy gets a redirect
(3xx) response:
- invoke returns the response from following the redirect response.
- proxy does not follow 3xx responses, and the redirect response is returned.
- The API Connect test tool shows that proxy was used, but invoke appears in the Analytics latency records.
- The response from the proxy can contain different whitespace or escaping than a response from invoke. Despite the differences in the response, it is still valid.
The following table describes the properties of the invoke policy.
| Property | Required | Description | Data type |
|---|---|---|---|
| title | No | A title for the policy. | string |
| description | No | A policy description. | string |
| target-url | Yes | The URL of the target API. | string |
| tls-profile | No | The TLS profile to be used. | string |
| verb | No |
The operation method type. Valid values:
The default value is |
string |
| timeout | No | The timeout value in seconds. The default value is 60. |
integer |
| compression | No | Specifies whether data is to be compressed by using gzip before it is uploaded. The default
value is false. |
Boolean |
| username | No | The user name, if authentication is required. | string |
| password | No | The password, if authentication is required. | string |
| output | No | The name of a variable that will be used to store the response data from the request. By
default, the invoke response, that is the body, headers, statusCode and statusMessage, is saved in
the variable message. Use this property to specify an alternate location to store
the invoke response. This variable can then be referenced in other actions, such as map. Note: If you want the response to be saved in
message, leave the output property blank, do not
supply the value message.
|
string |
|
|
No | Specifies the unique identifier of the document cache entry. | string |
|
|
No | The cache response type. Valid values:
The default value is |
string |
| cache-putpost-response | No | Specifies whether to cache the response from POST and PUT requests. Caching the response from POST and PUT requests can reduce server load and reduce latency in the response to the client request. The default value is |
boolean |
|
|
No | Specifies the amount of time in seconds that the response stays in the cache. Applies only if
the property cache-response is set to time-to-live. Enter a
value in the range 5 - 31708800. The default value is |
integer |
| stop-on-error | No | List the errors that, if thrown during the policy execution, cause the flow to stop. If there
is a catch flow configured for the error, it is triggered to handle the error
thrown. If an error is thrown and there are no errors specified for the Stop on
error property, or if the error thrown is not one of the specified errors, the policy
execution is allowed to complete, and the assembly flow continues. |
Boolean |
Example
- invoke:
title: get the account status
target-url: https://example.com/accounts/{id}?status={status}
cache-response: time-to-live
cache-putpost-response: true
tls-profile: MyTLSProfile
verb: POST
timeout: 60
compression: false
username: MyUser
password: MyPassword
stop-on-error:
- ConnectionError