Skip to content

Latest commit

 

History

History
121 lines (95 loc) · 2.56 KB

README.adoc

File metadata and controls

121 lines (95 loc) · 2.56 KB

HTTP Callout Policy

Build status Gitter

Phase

onRequest onResponse onRequestContent onResponseContent

X

-

-

-

Description

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.

Configuration

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

-

Sample
"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')}"
    }]
}

Http Status Code

Code Message

500

An error occurs while doing HTTP call.