Sample code for 30+ languages & platforms
Lua

qa.factura1.com.co Obtain Auth Token

See more HTTP Misc Examples

Demonstrates how to send a JSON POST to get an authenticataion token for qa.factura1.com.co

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.

local http = chilkat.Http.new()

-- Build the following JSON
-- {
--   "password": "MY_PASSWORD",
--   "username": "MY_USERNAME"
-- }

local json = chilkat.JsonObject.new()
json.emit_compact = false
json:update_string("password", "MY_PASSWORD")
json:update_string("username", "MY_USERNAME")

local resp = chilkat.HttpResponse.new()
local success = http:http_json("POST", "https://qa.factura1.com.co/v2/auth", json, "application/json", resp)
if not success then
    print(http.last_error_text)
    return
end

local jsonResp = chilkat.JsonObject.new()
jsonResp.emit_compact = false
jsonResp:load(resp.body_str)

print(jsonResp:emit())

print("Access token: " .. jsonResp:string_of("token"))