Sample code for 30+ languages & platforms
Lua

Adobe Analytics Reporting API (1.4)

See more HTTP Misc Examples

Demonstrates a simple POST of JSON to the Adobe Analytics Reporting API (v1.4)

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

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

-- In this example, replace "rsid" with your report suite id, and update the URL to use the correct endpoint
local url = "https://api.omniture.com/admin/1.4/rest/?method=Report.Queue"

local json = chilkat.JsonObject.new()
json:update_string("reportDescription.reportSuiteID", "rsid")
json:update_string("reportDescription.dateGranularity", "hour")

local http = chilkat.Http.new()

local dt = chilkat.DateTime.new()
dt:set_from_current_system_time()
local timecreated = dt:get_as_timestamp(false)

local prng = chilkat.Prng.new()
local nonce = prng:gen_random(12, "hex")

local secret = "SECRET"

local sb = chilkat.StringBuilder.new()
sb:append(nonce)
sb:append(timecreated)
sb:append(secret)

local crypt = chilkat.Crypt2.new()
crypt.hash_algorithm = "sha1"
crypt.encoding_mode = "base64"
local digest = crypt:hash_string_enc(sb:get_as_string())

local sbNonce = chilkat.StringBuilder.new()
sbNonce:append(nonce)
sbNonce:encode("base64", "utf-8")

sb:clear()
sb:append("UsernameToken Username=\"USERNAME\", PasswordDigest=\"")
sb:append(digest)
sb:append("\", Nonce=\"")
sb:append(sbNonce:get_as_string())
sb:append("\", Created=\"")
sb:append(timecreated)
sb:append("\"")

print(sb:get_as_string())

http:set_request_header("X-WSSE", sb:get_as_string())

local resp = chilkat.HttpResponse.new()
local success = http:http_json("POST", url, json, "text/json", resp)
if not success then
    print(http.last_error_text)
    return
end

print("Http Status code: " .. resp.status_code)
print("JSON response:")
print(resp.body_str)