Sample code for 30+ languages & platforms
Node.js

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 Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

    // 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
    var url = "https://api.omniture.com/admin/1.4/rest/?method=Report.Queue";

    var json = new chilkat.JsonObject();
    json.UpdateString("reportDescription.reportSuiteID","rsid");
    json.UpdateString("reportDescription.dateGranularity","hour");

    var http = new chilkat.Http();

    var dt = new chilkat.CkDateTime();
    dt.SetFromCurrentSystemTime();
    var timecreated = dt.GetAsTimestamp(false);

    var prng = new chilkat.Prng();
    var nonce = prng.GenRandom(12,"hex");

    var secret = "SECRET";

    var sb = new chilkat.StringBuilder();
    sb.Append(nonce);
    sb.Append(timecreated);
    sb.Append(secret);

    var crypt = new chilkat.Crypt2();
    crypt.HashAlgorithm = "sha1";
    crypt.EncodingMode = "base64";
    var digest = crypt.HashStringENC(sb.GetAsString());

    var sbNonce = new chilkat.StringBuilder();
    sbNonce.Append(nonce);
    sbNonce.Encode("base64");

    sb.Clear();
    sb.Append("UsernameToken Username=\"USERNAME\", PasswordDigest=\"");
    sb.Append(digest);
    sb.Append("\", Nonce=\"");
    sb.Append(sbNonce.GetAsString());
    sb.Append("\", Created=\"");
    sb.Append(timecreated);
    sb.Append("\"");

    console.log(sb.GetAsString());

    http.SetRequestHeader("X-WSSE",sb.GetAsString());

    var resp = new chilkat.HttpResponse();
    success = http.HttpJson("POST",url,json,"text/json",resp);
    if (success == false) {
        console.log(http.LastErrorText);
        return;
    }

    console.log("Http Status code: " + resp.StatusCode);
    console.log("JSON response:");
    console.log(resp.BodyStr);

}

chilkatExample();