Vital.sandbox
Rest

rest.post

Shared

Executes a POST request on specified url


Syntax

local response, error = rest.post(url, body, headers = {
    "Content-Type: application/json"
})

Requires execution within a valid thread context for asynchronous, non-blocking operation.
Calls made outside a thread will fail to process.

Parameters

TypeNameDescription
stringurlRequest URL to query
stringbodyRequest body for query
tableheadersRequest headers for query

Returns

TypeNameDescription
string / boolresponseResponse on successful execution, or false on failure
string / boolerrorfalse on successful execution, or error on failure

Examples

engine.print("Response:", rest.post("https://api.example.com/users", table.encode({
    name: "John Doe",
    email: "john@example.com"
}, "JSON")))

On this page