Skip to content

http_post

http_post(url, body, [headers]) performs an HTTP POST request. Returns (response, nil) on success or (nil, error_table) on failure.

http_post(url, body, [headers])
async
Param Type Description
url string Target URL
body string Request body
headers table? Optional key-value header pairs

Same as http_get.

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)
return
end