DataFlex
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
String sUrl
Variant vJson
Handle hoJson
Handle hoHttp
Handle hoDt
String sTimecreated
Handle hoPrng
String sNonce
String sSecret
Handle hoSb
Handle hoCrypt
String sDigest
Handle hoSbNonce
Variant vResp
Handle hoResp
String sTemp1
Integer iTemp1
Move False To iSuccess
// 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
Move "https://api.omniture.com/admin/1.4/rest/?method=Report.Queue" To sUrl
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Get ComUpdateString Of hoJson "reportDescription.reportSuiteID" "rsid" To iSuccess
Get ComUpdateString Of hoJson "reportDescription.dateGranularity" "hour" To iSuccess
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
Get Create (RefClass(cComCkDateTime)) To hoDt
If (Not(IsComObjectCreated(hoDt))) Begin
Send CreateComObject of hoDt
End
Get ComSetFromCurrentSystemTime Of hoDt To iSuccess
Get ComGetAsTimestamp Of hoDt False To sTimecreated
Get Create (RefClass(cComChilkatPrng)) To hoPrng
If (Not(IsComObjectCreated(hoPrng))) Begin
Send CreateComObject of hoPrng
End
Get ComGenRandom Of hoPrng 12 "hex" To sNonce
Move "SECRET" To sSecret
Get Create (RefClass(cComChilkatStringBuilder)) To hoSb
If (Not(IsComObjectCreated(hoSb))) Begin
Send CreateComObject of hoSb
End
Get ComAppend Of hoSb sNonce To iSuccess
Get ComAppend Of hoSb sTimecreated To iSuccess
Get ComAppend Of hoSb sSecret To iSuccess
Get Create (RefClass(cComChilkatCrypt2)) To hoCrypt
If (Not(IsComObjectCreated(hoCrypt))) Begin
Send CreateComObject of hoCrypt
End
Set ComHashAlgorithm Of hoCrypt To "sha1"
Set ComEncodingMode Of hoCrypt To "base64"
Get ComGetAsString Of hoSb To sTemp1
Get ComHashStringENC Of hoCrypt sTemp1 To sDigest
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbNonce
If (Not(IsComObjectCreated(hoSbNonce))) Begin
Send CreateComObject of hoSbNonce
End
Get ComAppend Of hoSbNonce sNonce To iSuccess
Get ComEncode Of hoSbNonce "base64" To iSuccess
Send ComClear To hoSb
Get ComAppend Of hoSb 'UsernameToken Username="USERNAME", PasswordDigest="' To iSuccess
Get ComAppend Of hoSb sDigest To iSuccess
Get ComAppend Of hoSb '", Nonce="' To iSuccess
Get ComGetAsString Of hoSbNonce To sTemp1
Get ComAppend Of hoSb sTemp1 To iSuccess
Get ComAppend Of hoSb '", Created="' To iSuccess
Get ComAppend Of hoSb sTimecreated To iSuccess
Get ComAppend Of hoSb '"' To iSuccess
Get ComGetAsString Of hoSb To sTemp1
Showln sTemp1
Get ComGetAsString Of hoSb To sTemp1
Send ComSetRequestHeader To hoHttp "X-WSSE" sTemp1
Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
If (Not(IsComObjectCreated(hoResp))) Begin
Send CreateComObject of hoResp
End
Get pvComObject of hoJson to vJson
Get pvComObject of hoResp to vResp
Get ComHttpJson Of hoHttp "POST" sUrl vJson "text/json" vResp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComStatusCode Of hoResp To iTemp1
Showln "Http Status code: " iTemp1
Showln "JSON response:"
Get ComBodyStr Of hoResp To sTemp1
Showln sTemp1
End_Procedure