http_post
http_post(url, body, [headers]) performs an HTTP POST request. Returns (response, nil) on success or (nil, error_table) on failure.
Signature
Section titled “Signature”http_post(url, body, [headers])
asyncParameters
Section titled “Parameters”| Param | Type | Description |
|---|---|---|
url |
string | Target URL |
body |
string | Request body |
headers |
table? | Optional key-value header pairs |
Returns
Section titled “Returns”Same as http_get.
Example
Section titled “Example”local res, err = http_post("https://api.example.com", '{"foo":"bar"}', { ["Content-Type"] = "application/json", ["Accept"] = "application/json"})if not res then log("post failed: " .. err.error) returnendSee Also
Section titled “See Also”- http_get - HTTP GET request
- http_request - Arbitrary HTTP request with proxy/timeout support