HTTP Request
HTTP Request is a Pipe for executing HTTP requests to external services. It supports GET, POST, PUT, DELETE methods, various request body formats, and basic authentication.
Request Body Format
Depending on the value of params.content_type, data is transmitted differently:
content_type | Where data comes from |
|---|---|
form | From params.form — sent as URL GET parameters |
form-data | From params.form — sent as multipart/form-data |
json | From $in.body (byte array, usually prepared by the Pack pipe) |
xml | From $in.body (byte array, usually prepared by the Pack pipe) |
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
url | string | No | "" | Request URL. Supports templating |
method | string | No | GET | HTTP method: GET, POST, PUT, DELETE |
content_type | string | No | form | Body format: form, form-data, json, xml |
timeout | number | No | PIPE_HTTP_TIMEOUT | Request timeout in seconds |
success_codes | number[] | No | [200, 201, 202, 203, 204, 205, 206, 207, 208] | HTTP codes that route the event to outs.success |
headers | object | No | — | Request headers. Supports templating |
form | object | No | — | Form data for content_type: form and form-data. Supports templating |
auth_type | string | No | basic | Authentication type. The only available value is basic. Activated if auth_username is set. Sets the header Authorization: Basic <username>:<password> |
auth_username | string | No | "" | Login for basic authentication |
auth_password | string | No | "" | Password for basic authentication |
pool_size | number | No | PIPE_HTTP_MAX_CONN | Connection pool per host within the channel. Increasing pool_size may not improve speed without increasing PIPE_WORKER_SIZE in the configuration file |
limit | object | No | — | Rate limit for requests (see below) |
Rate Limit (limit)
Allows limiting the number of requests within a given time interval.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
period_sec | number | Yes | — | Interval in seconds |
count_requests | number | Yes | — | Maximum number of requests per interval. The limit applies within the key scope in the channel |
key | string | No | random UUID | Limit key. Supports templating. One key = one shared limit across multiple HTTP Request pipes |
tip
By default, the request rate depends on the Pipeline configuration and is approximately 200–300 requests per second.
Possible Errors
- Template processing error in pipe fields
$in.bodynot found (Pack pipe is missing before HTTP Request withcontent_type: jsonorxml)$in.bodyis not a byte array- Invalid value of
params.content_type - Invalid value of
params.method - HTTP request error (network error, timeout, etc.)
Examples
Form Request
{
"id": 3,
"type": "http_request",
"params": {
"method": "POST",
"timeout": 10,
"content_type": "form",
"form": {
"login": "$sender.login",
"password": "$sender.password",
"externalUserCode": "$sender.login"
},
"url": "https://example.com/api/v1.0/sessions",
"success_codes": [200, 202]
},
"outs": {
"success": 6,
"error": 7
}
}
JSON Body Request
Before this pipe in the chain, there must be a Pack pipe that builds the JSON and writes it to $in.body.
{
"id": 2,
"type": "http_request",
"params": {
"method": "POST",
"timeout": 10,
"content_type": "json",
"headers": {
"Authorization": "$in.ow_tp $in.ow_token"
},
"url": "https://example.com/api/v1/api/campaign/start",
"success_codes": [200, 202]
},
"outs": {
"success": 9,
"error": 10
}
}