-- Body payload object
local payload = {}
-- Specify our community ID, API key, and API method type (Panic)
payload["id"] = "YOUR_COMMUNITY_ID"
payload["key"] = "YOUR_API_KEY"
payload["type"] = "UNIT_PANIC"
-- Data: List (array) of unit panic objects
-- Here, we're specifying one unit to PANIC
local postData = {
{
["apiId"] = "STEAM:5678", -- Unit with their API ID set as `STEAM:5678`
["isPanic"] = true -- Panic ON
},
}
-- Add this data to our payload
payload["data"] = postData
-- Send POST request with JSON encoded body (payload)
PerformHttpRequest("https://api.sonorancad.com/emergency/unit_panic", function(statusCode, res, headers)
if statusCode == 200 and res ~= nil then
-- Status code 200 (Success)
print("result: "..tostring(res))
else
-- Error code
print(("CAD API ERROR: %s %s"):format(statusCode, res))
end
end, "POST", json.encode(payload), {["Content-Type"]="application/json"})