Http Request

A frozen node that calls an HTTPS address on the allowlist of the service and branches on the answer, in the versions published with it.

6 min read

Http Request makes one HTTPS call to an API outside Slen and puts the answer into the execution. The node is frozen unless the service is set up otherwise: the palette does not offer it, and a new version may not hold it. A version published with it goes on running, and this page says what the node does there.

Node
Http Request Frozen
Type
http_request
Category
Output
Ports
  • Default default must be connected
  • Error error optional
Ends the path
No
Frozen
No longer offered in the palette. Flows that already use it keep working.

What it does

The node builds one request from its settings and the values of the execution, makes the call and reads the answer. An answer with a 2xx status leaves through Default. Everything else leaves through Error: another status, a redirect included — the node does not follow one; a request it could not build; an address the service refuses; a host it could not reach; an answer longer than the node may read.

  • The address is always https on port 443, and its host is a name on the allowlist of the service — the host itself or a subdomain of it. The allowlist is one for the whole service, and whoever runs the service sets it. With an empty allowlist the node calls nothing.

  • Before every call the node checks the host against the allowlist again, and refuses a host whose name leads to an address that is not public. The call goes through no proxy.

  • The node spends time, not money: it holds and charges nothing.

When to use it

A new version cannot hold the node, so you meet it in a version published before the node was frozen. A draft that still holds it is not published until the node is taken out — Publish, versions and rollback says how the check reads.

To bring data of another API into a request, call that API from your application, and send what it answered in the input or the context of the request — Send a request.

Settings

SettingWhat it is for
methodThe method of the request — GET, POST, PUT, PATCH or DELETE. GET when it is not set.
urlThe address the node calls — https, port 443, a host on the allowlist of the service. Its path and query may hold placeholders, a path in double braces, filled with values of the execution; the host may not.
headersHeaders sent with the request, a name to a text value, at most 10. A header that carries a credential is refused.
body_fromA path to the value sent as the body, whole, as JSON. Used with POST, PUT and PATCH only; without it the request has no body.
timeout_secondsHow long the node waits for the answer, in seconds. Without it the default of the service applies; it may not exceed the ceiling of the service.
max_response_bytesHow many bytes of the answer the node reads. A longer answer is not read. Without it the default of the service applies; it may not exceed the ceiling of the service.
  • A placeholder is a path in double braces, such as {{input.customer_id}}: the path of the address and its query may hold them, the host may not. The node fills each with the value at the path, encoded for an address. A number is written as it is, and true and false as words. A path that finds nothing, null, a list or an object is not filled: the node makes no call and leaves through Error.

  • A path into nodes names a node that runs before this one.

  • The node asks for JSON. With a body it sends Content-Type: application/json.

  • A header that carries a credential — an authorization, a cookie, an API key — is refused: the flow is stored as plain JSON, and such a header would keep a secret in plain text.

  • Unless the service is set up otherwise, the node waits 5 seconds for an answer and at most 15, and reads 65,536 bytes of it and at most 262,144. The connection itself has to be made within 3 seconds.

Ports

The node has two ports. Default is required: a flow in which it leads nowhere is not published. Error is optional. When it leads nowhere and the call fails, the execution ends failed with the code http_request_failed.

Output

The output is the answer: its status, its body when the body is a JSON object or list, its text otherwise.

JSON
{ "status": 200, "body": { "tier": "pro" }, "text": null, "error_code": null }

A call that got no answer leaves status empty and says why in error_code:

JSON
{ "status": null, "body": null, "text": null, "error_code": "host_not_allowed" }

A later node reads the answer as nodes.<key>.output.body — here nodes.call.output.body.tier, when the key of the node is call. Return Response with the source Output of a node answers with the whole output.

Errors

The node writes one http_called event into the trace for each call. The event names the method, the host, the path as the author wrote it — the placeholders unfilled — the status, the time and the size of the answer. What a placeholder was filled with, the query and the headers are not written. A call that produced no answer carries a reason.

JSON
[
  { "type": "http_called", "node_key": "call", "payload": { "method": "GET", "host": "api.example.com", "path": "/v1/customers/{{input.customer_id}}", "status": 404, "duration_ms": 182, "bytes": 61, "reason": null } },
  { "type": "http_called", "node_key": "call", "payload": { "method": null, "reason": "url_placeholder_unresolved" } },
  { "type": "http_called", "node_key": "call", "payload": { "method": null, "reason": "body_unresolved" } },
  { "type": "http_called", "node_key": "call", "payload": { "method": null, "reason": "url_unparseable" } },
  { "type": "http_called", "node_key": "call", "payload": { "method": "GET", "host": "api.example.com", "path": "/v1/plans", "status": null, "duration_ms": 0, "bytes": 0, "reason": "egress_not_configured" } },
  { "type": "http_called", "node_key": "call", "payload": { "method": "GET", "host": "api.example.com", "path": "/v1/plans", "status": null, "duration_ms": 0, "bytes": 0, "reason": "host_not_allowed" } },
  { "type": "http_called", "node_key": "call", "payload": { "method": "GET", "host": "203.0.113.7", "path": "/v1/plans", "status": null, "duration_ms": 0, "bytes": 0, "reason": "host_is_address_literal" } },
  { "type": "http_called", "node_key": "call", "payload": { "method": "GET", "host": "api.example.com", "path": "/v1/plans", "status": null, "duration_ms": 12, "bytes": 0, "reason": "host_unresolvable" } },
  { "type": "http_called", "node_key": "call", "payload": { "method": "GET", "host": "api.example.com", "path": "/v1/plans", "status": null, "duration_ms": 9, "bytes": 0, "reason": "address_not_public" } },
  { "type": "http_called", "node_key": "call", "payload": { "method": "GET", "host": "api.example.com", "path": "/v1/plans", "status": null, "duration_ms": 5004, "bytes": 0, "reason": "unreachable" } },
  { "type": "http_called", "node_key": "call", "payload": { "method": "GET", "host": "api.example.com", "path": "/v1/plans", "status": 200, "duration_ms": 1310, "bytes": 2048, "reason": "request_failed" } },
  { "type": "http_called", "node_key": "call", "payload": { "method": "GET", "host": "api.example.com", "path": "/v1/plans", "status": 200, "duration_ms": 240, "bytes": 65537, "reason": "response_too_large" } }
]
reasonWhat happened
url_placeholder_unresolvedA placeholder of the address could not be filled. Nothing was called
body_unresolvedThe path of the body found nothing. Nothing was called
url_unparseableThe address cannot be read. Nothing was called
egress_not_configuredThe allowlist of the service is empty
host_not_allowedThe host is no longer on the allowlist
host_is_address_literalThe address names an IP address instead of a host
host_unresolvableThe name of the host leads to no address
address_not_publicThe name of the host leads to an address that is not public
unreachableNo connection was made, or no answer came within the time of the node
request_failedThe call broke after the connection was made
response_too_largeThe answer is longer than the node may read

An answer with a status outside 2xx has no reason: the status says what happened.

A draft that holds the node is refused with node_type_frozen — Publish checks. The settings of the node are checked as well, when the flow is validated and when it is published:

In the API an entry of issues names such a check in params.detail; its code is invalid_node_config.

CheckMessage in the builder
http_needs_url“{node}” needs a url.
http_templated_host“{node}” may not template its host.
http_egress_not_configured“{node}” cannot call out: no outbound host is configured.
http_host_not_allowedThe url of “{node}” is not on the outbound allowlist (allowed: {hosts}).
http_scheme_not_https“{node}” must call https.
http_port_not_allowed“{node}” may only call port 443.
http_url_has_credentialsThe url of “{node}” carries credentials.
http_host_is_address_literal“{node}” must call a host name, not an address.
http_url_unparseableThe url of “{node}” cannot be read.
http_url_bad_placeholderThe url of “{node}” has a placeholder that names no value in input, context or the output of a node — the call would fail on every run.
http_url_unknown_nodeThe url of “{node}” reads “{path}”, but the flow has no node “{ref}”.
http_url_later_nodeThe url of “{node}” reads “{path}”, but “{ref}” does not run before it.
http_unsupported_method“{node}” uses an unsupported method.
http_headers_not_mapThe headers of “{node}” must be a map of names to values.
http_too_many_headers“{node}” sets more than {max} headers.
http_header_unusable_name“{node}” has a header with an unusable name.
http_header_forbidden“{node}” may not set “{header}”: the graph is stored as plain text, so a credential here would not be a secret.
http_header_needs_valueThe header “{header}” of “{node}” needs a text value.
http_invalid_timeout“{node}” may wait between 1 and {max} seconds.
http_invalid_max_bytes“{node}” may read up to {max} bytes.
http_invalid_body_fromThe body path of “{node}” must point into the execution.
http_body_from_unknown_nodeThe body of “{node}” is read from “{path}”, but the flow has no node “{ref}”.
http_body_from_later_nodeThe body of “{node}” is read from “{path}”, but “{ref}” does not run before it.

Example

  • Request — Default → Http Request
  • Http Request — Default → Return Response
  • Http Request — Error → Reject Request

The node calls the address of its settings with the customer of the request in the path. Return Response answers with the output of the node. When the call fails, the execution goes to Reject Request and ends rejected with the code the node is set to.

Built from openapi b070e1f, sdk contract 5cc7055, php ae4a53b, node 84bc62d