I needed to get some log messages out of sparkpost, but couldn't find anything here or in the AA documentation. Had a bit of a play around and managed to pull some records into a pointer variable for onward processing. I hope this snippet may be of use to others.
Code:
'Date Created: 11-Oct-2014 02:57:06 PM 'Last Updated: 25-Jan-2017 10:08:07 AM 'Created By : Jon 'Updated By : Jon 'Retrieve bounce log entries from Sparkpost 'Test version set to pull all bounces since 2017-06-10 'Need to parameterize URL to add other options listed at https://developer.sparkpost.com/api/message-events.html '******************************************** 'ARMAsoft only - get Sparkpost Key from table '******************************************** 'select email account and details for send depending on C_ID2 prefix DIM account as P account = table.open("email_accounts",FILE_RO_SHARED) dim key as c = alltrim(account.password) account.close() 'Code below generated by Alpha Anywhere cURL to XBasic wizard dim cf_1 as extension::CurlFile dim flag_1 as l dim slist1[0] as c = [ "Content-Type: application/json" , "Authorization: " + key ] dim ce as extension::Curl ce = extension::Curl.Init() ce.setOpt("URL","https://api.sparkpost.com/api/v1/message-events?events=bounce&from=2017-06-10T11:00") ce.setOpt("NOPROGRESS",1) ce.setOpt("USERAGENT","curl/7.34.0") ce.setOpt("HTTPHEADER",slist1) ce.setOpt("MAXREDIRS",50) ce.setOpt("CAINFO",a5.Get_Exe_Path()+"\caroot\ca-cert.pem") ce.setOpt("CAPATH",a5.Get_Exe_Path()+"\caroot") ce.setOpt("CUSTOMREQUEST","GET") ce.setOpt("VERBOSE",1) ce.setOpt("TCP_KEEPALIVE",1) ce.SetOpt("FILE",cf_1) flag_1 = ce.Exec() if flag_1 then dim headers as c dim contents as c headers = cf_1.GetHeaders() contents = cf_1.GetContent() 'parse results from Sparkpost and populate multi-level array, required elements in arr.results[n] dim arr as p dim ecount as N dim i as N arr = json_parse(contents) 'get number of elements ecount = arr.results.size() 'loop through each element of the result... for i = 1 to ecount showvar(arr.results[i]) next end if ce.close()