Dart
Dart
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 Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
// 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
final url = 'https://api.omniture.com/admin/1.4/rest/?method=Report.Queue';
final json = CkJsonObject();
json.updateString('reportDescription.reportSuiteID', 'rsid');
json.updateString('reportDescription.dateGranularity', 'hour');
final http = CkHttp();
final dt = CkDateTime();
dt.setFromCurrentSystemTime();
final timecreated = dt.getAsTimestamp(false);
final prng = CkPrng();
final nonce = prng.genRandom(12, 'hex');
final secret = 'SECRET';
final sb = CkStringBuilder();
sb.append(nonce);
sb.append(timecreated);
sb.append(secret);
final crypt = CkCrypt2();
crypt.hashAlgorithm = 'sha1';
crypt.encodingMode = 'base64';
final digest = crypt.hashStringENC(sb.getAsString());
final sbNonce = CkStringBuilder();
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('"');
print(sb.getAsString());
http.setRequestHeader('X-WSSE', sb.getAsString());
final resp = CkHttpResponse();
try {
http.httpJson('POST', url, json, 'text/json', resp);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
print('Http Status code: ${resp.statusCode}');
print('JSON response:');
print(resp.bodyStr);
}