nyno-http-post
nyno-http-post — Perform an HTTP POST request in a workflow
Description
- step: nyno-http-post
args:
- 'https://nyno.dev/test-post'
- { name: "Alice" }
- { "X-Custom-Header": "MyValue" }
The nyno-http-post step sends an HTTP POST request to the specified URL with an optional JSON body and optional headers. The response is stored in the workflow context (${prev} by default or a custom key via set_context).
- On success, it returns the HTTP status and response text.
- On failure, it stores an error object in the context.
Usage in a workflow YAML:
workflow:
- step: nyno-http-post
args:
- 'https://nyno.dev/test-post'
- { name: "Alice" }
- { "X-Custom-Header": "MyValue" }
Parameters
| Parameter | Type | Description |
|---|---|---|
url |
string |
The URL to send the POST request to. Must include protocol (http:// or https://). |
body |
object |
Optional JSON-serializable body to include in the POST request. |
headers |
object |
Optional headers to include in the request. Defaults to { "Content-Type": "application/json" }. |
Return Values
- Returns
0if the request succeeds (HTTP status2xx),1if the request fails with HTTP error,-1if there is a network or fetch exception. - Context (
${prev}by default, or custom viaset_context) contains:
{
"HTTP_RESPONSE": "...response body as string...",
"HTTP_STATUS": 200,
"HTTP_ERROR": null
}
- On failure (non-2xx HTTP status),
HTTP_ERRORis set:
{
"HTTP_RESPONSE": "...",
"HTTP_STATUS": 404,
"HTTP_ERROR": "HTTP error 404"
}
- On network or exception errors,
HTTP_ERRORcontains the error message,HTTP_RESPONSEmay be empty.
Behavior
- Performs an HTTP POST request with optional JSON body and headers.
- Automatically sets
"Content-Type": "application/json"unless overridden in headers. - Stores the response text and HTTP status in context.
- Uses
${prev}by default or a custom context key ifset_contextis specified. - Records the last HTTP method used in
context.last_http_method = 'post'.
Examples
Example #1 — Basic POST request
workflow:
- step: nyno-http-post
args:
- 'https://api.example.com/data'
- { name: "Alice" }
Stores the response in ${prev}:
{
"HTTP_RESPONSE": "...",
"HTTP_STATUS": 200,
"HTTP_ERROR": null
}
Example #2 — Custom headers
workflow:
- step: nyno-http-post
args:
- 'https://api.example.com/data'
- { name: "Alice" }
- { "X-Custom-Header": "MyValue" }
Example #3 — Custom context key
workflow:
- step: nyno-http-post
args:
- 'https://api.example.com/data'
- { action: "send" }
context:
set_context: api_response
Stores the response under ${api_response}.
Notes
- Only POST requests are supported.
- The body is automatically JSON-encoded.
- Non-2xx responses are treated as failures (
output=1), but response content is still returned. - Use
set_contextto avoid overwriting${prev}when multiple HTTP requests are used in one workflow.
See Also
- nyno-http-get: Perform HTTP GET requests.
- nyno-file-write / nyno-file-read: Save or read request/response data to/from files.