How To Call It
This is an object method: call it with a colon on a request object created with Request(url) (request:<method>(...)). The global Request table does not have this method.
Adds a request header; returns the request object.
Documented for app version 1.0.51Updated:
This is an object method: call it with a colon on a request object created with Request(url) (request:<method>(...)). The global Request table does not have this method.
For network integration, use HTTPS only, keep the response size bounded, and validate the response code before moving into JSON or File steps.
Required: key, value. Returns a Request object.
Limits: only HTTPS addresses are accepted; a request body may be up to 1 MB and a response up to 5 MB; connect and read time out after 10 and 15 seconds (at most 60 seconds with setTimeout); setRetry makes at most 4 attempts. Request calls are limited to 30 per second. On the response object getResponseCode() returns the HTTP status and getData() the body text.
The most common pattern is to check a Request response with getResponseCode(), read its body with getData() and parse it with JSON.parse().
The snippet below is a starter pattern that can be applied directly in runtime flow.
local request = Request("https://example.com/api/status")
local result = request:setHeader("Accept", "application/json")From foundation to combined usage, each level is provided as a separate code block so you can copy the level you need and adapt it directly.
local request = Request("https://example.com/api/status")
local result = request:setHeader("Accept", "application/json")local stepOk = true
local request = Request("https://example.com/api/status")
local result = request:setHeader("Accept", "application/json")
if stepOk then
wait(200)
endlocal ok, err = pcall(function()
local request = Request("https://example.com/api/status")
local result = request:setHeader("Accept", "application/json")
end)
if not ok then
print("API step failed: Request:setHeader: " .. tostring(err))
requestStop()
end-- For network integration, use HTTPS only, keep the response size bounded, and validate the response code before moving into JSON or File steps.
local function run_setheader_step()
local request = Request("https://example.com/api/status")
local result = request:setHeader("Accept", "application/json")
end
local ok, err = pcall(run_setheader_step)
if not ok then
toast("Step failed")
print(err)
end-- POST a JSON body: Request.post(url) takes no body, so configure a request object
local request = Request("https://example.com/api/scores")
request:setContentType("application/json")
request:setBody(JSON.stringify({ level = 3, score = 1200 }))
local response = request:post()
if response:getResponseCode() == 200 then
print(response:getData())
else
print("HTTP " .. tostring(response:getResponseCode()))
end