SWebservice
Index
Functions Index
Functions
Get
void Get (string url, Closure onComplete, Table headers=null)
Performs an HTTP[S] GET. The callback receives two parameters: success (bool) and response (string).
url
string
The absolute URL to request.
onComplete
Closure
Callback (bool success, string response) invoked on completion.
headers
Table (optional)
Supported keys: Bearer (maps to Authorization: Bearer <token>), Content-Type (rarely used for GET).
-- Simple GET
local url = "https://httpbin.org/get"
Space.WebServices.Get(url, function(success, response)
if success then
Space.Log("OK: " .. response)
else
Space.Log("Request failed: " .. response)
end
end)Post
void Post (string url, string data, Closure onComplete, Table headers=null)
Performs an HTTP[S] POST. The callback receives two parameters: success (bool) and response (string).
url
string
The absolute URL to POST to.
data
string
Request body string. For JSON, send a JSON string and set Content-Type.
onComplete
Closure
Callback (bool success, string response) invoked on completion.
headers
Table (optional)
Supported keys: Content-Type (defaults to application/x-www-form-urlencoded), Bearer (maps to Authorization: Bearer <token>).
Note:
Server requests automatically include:
X-Sinespace-Region-ID,X-Sinespace-Instance-ID,X-Sinespace-Script-ID,X-Sinespace-Runtime-Type, andX-Sinespace-In-Editor.There is no
timeoutparameter on server web requests.
Last updated
Was this helpful?

