Skip to content

HTTP

HTTP:Request(options)

Places a new HTTP Request in the Queue

  • [REQUIRED] url is the request full url string
  • [REQUIRED] method can be any string aka GET,PUT,POST,OPTIONS,NilNAmE
  • [optional] callback is a function to be called after the Request completes.
  • [optional] headers is a table of string values to put as headers on the request
  • [optional] params are the request body used by every method besides GET
  • [optional] pin is a CERTPIN string
local function httpCallback(status,result)
    print(status,result)
end

local request = {
    callback = httpCallback,
    method = "POST",
    params = "request body goes here",
    url = "https://google.com",
    headers = {"Accept: application/json", "Content-Type: application/x-www-form-urlencoded"},
    pin = "sha256//YhKJKSzoTt2b5FP18fvpHo7fJYqQCjAa3HWY3tvRMwE=;sha256//t62CeU2tQiqkexU74Gxa2eg7fRbEgoChTociMee9wno="
}
HTTP:Request(request)

Deprecated

HTTP:GET(url, [params,] callBack)

Places a GET call to a HTTP API.

** Other variables are permitted, if you have specific questions, ask an admin.

local url = 'https://someApi.com' 
local headers = {"Accept: application/json", "Content-Type: application/x-www-form-urlencoded"}

local function callback(status, data)

    if status == 200 then 
     print ('Success! Your data is as follows:')
     print (data)
    else 
     print ('Failure code:', status)
    end
end
HTTP:GET(url, headers, callBack)

HTTP:POST(url, postData, callBack)

Place a POST call to a HTTP API.

** Other varaibles are permitted, if you have specific questions, ask an admin.

local url = 'https://httpbin.org/post?clue=yes&something=no' 
local postData =  "token: '1234567890abc', username: 'JackBauer'"

local function callback(status, data)

    if status == 200 then 
     print ('Success! Your data is as follows:')
     print (data)
    else 
     print ('Failure code:', status)
    end
end
HTTP:POST(url, postData, callback)