The callout HTTP
policy can be used to invoke an HTTP(S) URL and put the content or a sub part of the content into
one or more variables of request execution context.
This may be useful if you need some data from an external services and want to inject these data during request processing.
The result of the callout is put in a variable named calloutResponse
and is only available during the policy
execution. If no variable has been configured the result of the callout will not be available anymore.
Property | Required | Description | Type | Default |
---|---|---|---|---|
method |
X |
HTTP Method used to invoke URL |
HTTP method |
GET |
url |
X |
URL invoked by the HTTP client (support EL) |
URL |
- |
headers |
X |
List of HTTP headers used to invoke the URL (support EL) |
HTTP Headers |
- |
body |
X |
The body content send when calling the URL (support EL) |
string |
- |
variables |
X |
The variables to set in the execution context when retrieving content of HTTP call (support EL) |
List of variables |
- |
exitOnError |
X |
Terminate the request if the error condition is true |
boolean |
false |
errorCondition |
X |
The condition which will be verified to end the request (support EL) |
string |
{#calloutResponse.status >= 400 and #calloutResponse.status โ 599} |
errorStatusCode |
X |
HTTP Status Code send to the consumer if the condition is true |
int |
500 |
errorContent |
X |
The body response of the error if the condition is true (support EL) |
string |
- |
"policy-http-callout": {
"method": "GET",
"url": "https://api.gravitee.io/echo",
"headers": [ {
"name": "X-Gravitee-Request-Id",
"value": "{#request.id}"
}],
"variables": [{
"name": "my-server",
"value": "{#jsonPath(#calloutResponse.content, '$.headers.X-Forwarded-Server')}"
}]
}