> For the complete documentation index, see [llms.txt](https://docs.augelab.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.augelab.com/function-blocks/blocks-reference/input-output/communication/rest-api-request.md).

# REST API - Request

Unified REST request block for calling web APIs. Configure method, headers, query parameters and payload. Choose async (non-blocking) or sync (wait for response) runtime. Optionally extract a value from JSON response using a dotted/array path.

## 📥 Inputs <a href="#inputs" id="inputs"></a>

`Enable` Optional boolean to run the request. When False the block can skip sending a request (default True).

`Server Address` URL or endpoint to call (required).

`Headers` Optional headers as a dictionary or JSON string.

`Query Params` Optional query parameters as a dictionary or JSON string.

`Payload` Optional request body (will be sent according to selected body mode).

`Response Path` Optional text path used to extract a value from the JSON response (examples: data.items\[0].id or items\[2]).

(here sockets are inputs)

## 📤 Outputs <a href="#outputs" id="outputs"></a>

`OK` Boolean that is True when HTTP response indicates success.

`Status Code` HTTP status code returned by the server.

`Error` Error message for network/HTTP issues or parsing errors.

`Response Text` Raw response body as text.

`Response JSON` Parsed JSON object when available (otherwise None).

`Response Headers` Map of response headers.

`Elapsed (ms)` Request duration in milliseconds.

`Extracted Data` Value resolved from `Response JSON` using `Response Path` (or None if not found).

(here sockets are outputs)

## 🕹️ Controls <a href="#controls" id="controls"></a>

`Method` Choose HTTP method: GET / POST / PUT / PATCH / DELETE.

`Body Mode` Choose how to send `Payload`: json / form / raw.

`Runtime Mode` Choose execution mode: Async (non-blocking, keeps last result) or Sync (waits for response).

`Timeout (s)` Timeout in seconds for requests (invalid values fall back to a safe default).

`Verify SSL` Enable or disable TLS certificate verification (disable only for trusted test environments).

## ⚙️ How it works <a href="#how-it-works" id="how-it-works"></a>

* When `Enable` is true the block builds the request using the `Server Address`, `Headers`, `Query Params` and `Payload` along with chosen `Method` and `Body Mode`.
* In `Sync` mode the block waits until the HTTP request completes and returns the fresh result on the same evaluation cycle.
* In `Async` mode the block sends the request without blocking; the block keeps the last completed result and updates outputs once the background request finishes.
* A JSON extraction path provided to `Response Path` resolves into `Extracted Data` if present; empty path yields no extraction.
* On HTTP or network errors the block exposes an `Error` message and will mark the block result as invalid to help spotting failures.

## 📝 Usage <a href="#usage" id="usage"></a>

1. Set `Server Address` to your API endpoint.
2. Provide optional `Headers` and `Query Params` as dictionaries or JSON strings.
3. Put request body in `Payload` and choose `Body Mode` (use json for structured payloads).
4. Choose `Runtime Mode`:
   * Use `Async` to avoid blocking your scenario (good for UI/continuous pipelines).
   * Use `Sync` when you need the response immediately in the same run.
5. (Optional) Add a `Response Path` to extract a nested value from the JSON response for downstream logic.
6. Trigger the call by setting `Enable` to True or feeding a boolean trigger from other blocks.

## 💡 Tips and Tricks <a href="#tips-and-tricks" id="tips-and-tricks"></a>

* Prepare JSON payloads with the `Data to JSON` block before feeding into `Payload` for cleaner structure and fewer formatting mistakes.
* Use `Parse Data Dictionary` after `Response JSON` to safely access and route response fields if you prefer visual dictionary parsing.
* Log responses or periodic results using `CSV Export` to keep a timestamped record of API responses for analysis.
* For debugging flows, connect `Error` or `Response Text` to `Debug Input` to print or inspect unexpected outputs.
* Combine with `Logic Input` or `Rising Edge` to control exactly when requests are sent (for example send only once per event).

(here suggested blocks are from the provided list)

## 🛠️ Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

* Server Address empty or invalid: ensure `Server Address` is a full URL (including protocol if required).
* Request times out: increase `Timeout (s)` or ensure network connectivity to the server.
* SSL verification errors in test environments: temporarily disable `Verify SSL` only if you trust the target.
* Unexpected JSON parsing: check `Response Text` first; use a JSON-valid payload and set `Body Mode` to `json` when sending structured data.
* No extracted data: verify the structure by inspecting `Response JSON` and adjust `Response Path` using dot/index notation (e.g. items\[0].id).

## 🔒 Privacy & Safety <a href="#privacy-and-safety" id="privacy-and-safety"></a>

Be careful with sensitive data in `Headers` or `Payload` (API keys, passwords). When logging responses or exporting data, ensure sensitive fields are redacted.

## 🧭 Example workflows <a href="#examples" id="examples"></a>

* Send sensor data periodically to a web service and record success/failure counts with `CSV Export`.
* Post a structured JSON object created by `Data to JSON` and then feed `Extracted Data` into a decision flow (`Logic Input` / thresholds).
* Use `Debug Input` to inspect server errors during development before switching to production logging.
