request
Send a GET, POST, PUT, or DELETE request to a remote URL.
Parameters
Name | Type | Description |
---|---|---|
url | string | URL to send the HTTPS request to. Required. |
method | string | Request type. GET |POST |PUT |DELETE . Required. |
headers | object | Object containing HTTP headers to set. Valid header values are Accept , Authorization , Content-Type , Range , and custom X- headers. Optional. Default is not set. |
body | string | object | Request body. Content-Type header should be explicitly set, but if not set, the most likely type will be set based on the first non-whitespace character. Optional. Default is not set. |
timeout | number | Maximum time in seconds to wait for a response. Default is 5.0 . Optional. |
connect_timeout | number | Maximum time in seconds to wait for a connection. Default is 5.0 . Optional. |
save_variables | boolean | Store parsed JSON response as variables. Default is false . Optional. |
Variables
Set by the method:
- request_url: (out) URL the request was sent to.
- request_result: (out)
success
|failed
. - return_value: (out) The same value as the
request_result
. - request_response_code: (out) HTTP response code from the request.
- request_response_headers.
<header name lowercase>
: (out) HTTP response headers. Header names should be normalized to lowercase and trimmed of whitespace. A maximum of 64 headers are saved. Ex:%{request_response_headers.content-type}
. - request_response_body: (out) Raw HTTP response body. This is limited to 64KB.
- request_response.
<object_field>
: (out) Variables saved from the response ifsave_variables
is true and parsed as JSON.
For example, given the script:
{ "foo": "bar", "foo2": "bar2", "foo3": { "foo4": "bar4" } }
The variables request_response.foo
, request_response.foo2
, and request_response.foo3.foo4
are set.
Examples
Making a POST Request
- YAML
- JSON
version: 1.0.0
sections:
main:
- request:
url: https://example.com/status_update
method: POST
connect_timeout: 5
timeout: 5
save_variables: true
headers:
content-type: application/json
x-custom-header: foo
body:
payload: "%{call.to} finished the IVR."
{
"version": "1.0.0",
"sections": {
"main": [
{
"request": {
"url": "https://example.com/status_update",
"method": "POST",
"connect_timeout": 5.0,
"timeout": 5.0,
"save_variables": true,
"headers": {
"content-type": "application/json",
"x-custom-header": "foo"
},
"body": {
"payload": "%{call.to} finished the IVR."
},
}
}
]
}
}