Hi again everybody! You all have been super helpful in the past and I usually try as much as I can to figure out the answer before asking for help but this one seemingly goes over my head. I'm trying to write a simple script to pull information from my company's Zendesk ticketing system to quickly display info without combing through a case. I am an admin and created an API token and I'm trying to use some code that I found
https://the-automator.com/example-webservice-api-call-extract-json-binary-data-from-smartsheetshere I figured the code should be the same or similar but everytime I try, all I get as a response is that it couldn't authenticate me. Here's the code so far:
Code: Select all
#Include %A_LineFile%\..\JSON.ahk
case_ID:="<theCaseId>.json"
EndPoint:="https://<myCompanyName>.zendesk.com/api/v2/tickets/" case_ID
;***********API Call*******************
HTTP := ComObjCreate("WinHttp.WinHttpRequest.5.1")
HTTP.Open("GET", Endpoint . QueryString)
HTTP.SetCredentials("Authorization", "Basic <superLongToken>)
HTTP.SetRequestHeader("Accept", "application/json")
HTTP.Send()
URLDownloadToFile, https://<myCompanyName>.zendesk.com/api/v2/tickets/<theCaseId>.json, zdeskrma.json
FileRead json_str, zdeskrma.json
parsed := JSON.Load(json_str)
parsed_out := Format("
(Join`r`n
Subject: {}
RMA Number: {}
)"
, parsed.subject, parsed.30686198)
stringified := JSON.Dump(parsed,, 4)
stringified := StrReplace(stringified, "`n", "`r`n") ; for display purposes only
ListVars
WinWaitActive ahk_class AutoHotkey
ControlSetText Edit1, [PARSED]`r`n%parsed_out%`r`n`r`n[STRINGIFIED]`r`n%stringified%
WinWaitClose
return
I tried to scrub all the info that might identify my company...hopefully I didn't miss anything. Parsing the json info shouldn't be a problem, it's just accessing the data that seems to be my struggle right now. Not sure if I'm doing something wrong. I've been following
https://developer.zendesk.com/rest_api/docs/support/introduction but I don't know what I'm doing wrong.