REST API - Post
This function block sends JSON POST requests to a HTTP server address and returns the server response. It is designed for integration with external REST APIs while keeping the user interface responsive.
π₯ Inputs
Enable Condition β Logic signal to start a POST request when True.
Server Address β Text input for the full server endpoint (use full URL starting with http:// or https://).
Response Data ID β Optional key name to extract a specific field from a JSON response.
Post Data β Generic data payload that will be sent as JSON in the request body.
π€ Outputs
Status Code β HTTP status code returned by the server.
Error β Error message or reason when the request fails.
Response β Server response body or the extracted value when Response Data ID is provided.
πΉοΈ Controls
Timeout (s) β Number of seconds to wait before the request times out (adjust to suit slow/fast servers).
π¨ Features
Asynchronous requests: POST operations run in the background so the interface remains responsive.
Optional response parsing: If you provide a
Response Data IDthe block will attempt to return that specific field from a JSON response.Simple integration: Accepts a generic payload so you can send images, numbers, text or structured data prepared by other blocks.
βοΈ Running mechanism
When Enable Condition is True and a valid Server Address is provided, the block sends a POST request with the Post Data payload. The request uses the configured Timeout (s) and runs without blocking the UI. When the server responds, the block updates its outputs with Status Code, Error (if any), and Response (or the selected response field).
π Usage instructions
Provide the target endpoint in
Server Address(include http:// or https://).Connect or prepare the payload on the
Post Datainput (use other blocks to build structured data if needed).Use a logic signal on
Enable Conditionto trigger sending (e.g., manual toggle or a conditional block).Optionally set
Response Data IDto extract a specific field from the server's JSON response.Adjust
Timeout (s)if the server is slow or to avoid long waits.
π‘ Tips and Tricks
Use
Logic InputorRising Edgeto control when the request is sent (single-shot triggers or manual control).Prepare structured payloads with
Data to JSONbefore feeding intoPost Datafor reliable JSON formatting.Use
String Inputto provide theServer AddressorNumber Inputfor numeric fields inside the payload.Log or persist responses with
CSV ExportorImage Logger(if your payload/response contains images or timestamps).Pair with
REST API - Getwhen you need both POST and GET interactions with the same service (e.g., send data then poll for results).Include
Date-TimeorDate-Time Listin your payload to timestamp requests.Use
Debug Inputto inspect the request payload or server response during development.
π οΈ Troubleshooting
No response / network error: Verify that
Server Addressis correct, reachable from the machine, and includes the protocol (http/https). Check firewall or network settings.Authentication required: Ensure the target API accepts unauthenticated POSTs or add whatever authentication the service needs outside of this block (e.g., via headers managed by the server).
Invalid JSON or unexpected response: Use
Data to JSONto ensure payload is valid JSON, and check the API documentation for expected field names. If you requested a specificResponse Data IDand the field is missing, theResponseoutput may be empty.Timeouts: Increase
Timeout (s)for slow endpoints or check server load. If requests frequently time out, test the service separately to confirm responsiveness.Repeated triggers: If you only want to send a single POST per event, use
Rising Edgeto convert a continuous True signal into a single trigger.
If you need examples of how to chain this block with data formatting, logging or trigger controls, combine it with blocks such as Data to JSON, Logic Input, Rising Edge, CSV Export, and REST API - Get for common integration patterns.
Last updated
Was this helpful?