Sample code for 30+ languages & platforms
React Native

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 React Native Downloads

React Native
import { CkDateTime, Crypt2, Http, HttpResponse, JsonObject, Prng, StringBuilder } from '@chilkat/react-native'

async function chilkatExample() {
  // 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
  const url = 'https://api.omniture.com/admin/1.4/rest/?method=Report.Queue';

  const json = new JsonObject();
  json.updateString('reportDescription.reportSuiteID', 'rsid');
  json.updateString('reportDescription.dateGranularity', 'hour');

  const http = new Http();

  const dt = new CkDateTime();
  dt.setFromCurrentSystemTime();
  const timecreated = dt.getAsTimestamp(false);

  const prng = new Prng();
  const nonce = prng.genRandom(12, 'hex');

  const secret = 'SECRET';

  const sb = new StringBuilder();
  sb.append(nonce);
  sb.append(timecreated);
  sb.append(secret);

  const crypt = new Crypt2();
  crypt.hashAlgorithm = 'sha1';
  crypt.encodingMode = 'base64';
  const digest = crypt.hashStringENC(sb.getAsString());

  const sbNonce = new StringBuilder();
  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.getAsString());
  sb.append('", Created="');
  sb.append(timecreated);
  sb.append('"');

  console.log(sb.getAsString());

  http.setRequestHeader('X-WSSE', sb.getAsString());

  const resp = new HttpResponse();
  try {
    await http.httpJsonAsync('POST', url, json, 'text/json', resp);
  } catch {
    console.log(http.lastErrorText);
    return;
  }

  console.log(`Http Status code: ${resp.statusCode}`);
  console.log('JSON response:');
  console.log(resp.bodyStr);
}