Invoke (invoke)
Apply the Invoke policy to call another service from within your assembly. The response from the backend is stored either in the variable message.body or in the response object variable if it is defined. The policy can be used with JSON or XML data, and can be applied multiple times within your assembly.
About
- REST
- SOAP
- 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.
Properties
The following table lists the policy properties, indicates whether a property is required, specifies the valid and default values for input, and specifies the data type of the values.
Property label | Required | Description | Data type |
---|---|---|---|
Title | Yes | The title of the policy. The default value is |
string |
Description | No | A description of the policy. | string |
URL | Yes | Specifies a URL for the target service. For a SOAP API, a URL is added by default. Where possible, the Invoke URL value is pre-supplied from information that is defined in the imported WSDL. Additional configuration is required to call applications that are hosted on collectives. For more information, see Modifying the assembly to call an application endpoint hosted on a collective. |
string |
TLS profile | No | Specifies a TLS profile to use for the secure transmission of data. | string |
Timeout | Yes | The time to wait before a reply back from the endpoint (in seconds). The default value is
|
integer |
Username | No | The username to use for HTTP Basic authentication. | string |
Password | No | The password to use for HTTP Basic authentication. | string |
HTTP Method | Yes | The HTTP method to use for the Invoke. Valid values are:
GET . However, if set to Keep , or the
property is removed from the source, the HTTP method from the incoming request is used. |
string |
Compression | No | Select this check box to enable Content-Encoding compression on upload. The check box is cleared by default. |
boolean |
Cache Type |
No | The cache type determines whether to cache documents, honoring or overriding the HTTP Cache Control directives received in the response from the target URL. This property takes effect only when a response is received, otherwise the policy always returns the non-expired response that was previously saved in cache. Valid values are:
The default value is Protocol. |
string |
Time to Live |
No | Specifies the amount of time in seconds that the response stays in the cache. Applies only if
the property Cache type is set to Time to Live . Enter a
value in the range 5 - 31708800. The default value is |
integer |
Cache key |
No | Specifies the unique identifier of the document cache entry. If omitted, the entire URL string is used as the key. | string |
Stop on error | No | Select this check box to stop the flow and trigger a catch flow when a particular type of
error is thrown. The following list shows the type of errors that can be selected:
The check box is selected by default, but you must also select one or more error types in the search errors field, or the flow will not stop and no catch flows will be triggered. If the check box is not selected, or no error types are selected, the flow will continue when an error is thrown during the policy execution. |
boolean |
Response object variable |
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 Response object variable property
blank, do not supply the value message.
|
string |
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