Downloading JSON data from Zoom's API Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Coriel-11
Posts: 45
Joined: 18 Aug 2017, 09:02

Downloading JSON data from Zoom's API

Post by Coriel-11 » 27 Sep 2021, 07:15

Hi,
I've been trying for a while now to access data about who attended our Zoom webinars via the Zoom API.

Amongst other things I've been using Joe Glines' Zoom API v2 video (https://www.the-automator.com/zoom-api/) on this, but our IT team isn't really happy about using SCiTE and that, combined with my general unfamiliarity with APIs, means I'm unsure of what I'm doing wrong.

Ideally I'd be able to run something that just downloaded a raw JSON file - as my intention is then to bring it/them into Power BI which can handle the JSON formatting.

I've got the start of the thing OK I think, but I'm just not sure what to do at the end to save the info that's coming back to me as a file (or even just paste into notepad).

Here's my code

Code: Select all

#SingleInstance,Force
JWT_Token:="MY JWT TOKEN - EXCLUDED HERE FOR OBVIOUS REASONS"
EndPoint:="https://api.zoom.us/v2/metrics/webinars/{webinarId}/participants"
Reg:=API_Call("GET",Endpoint,QS,JWT_Token)
return

;********API call**********************
API_Call(Type,Endpoint,QS,JWT_Token){
	HTTP := ComObjCreate("WinHttp.WinHttpRequest.5.1") ;Creates COM Object
	HTTP.Open(TYPE,EndPoint QS) ;Starts the request
	HTTP.SetRequestHeader("Authorization","Bearer " JWT_Token) ;Authorisation from a JWT token
	HTTP.SetRequestHeader("Content-Type","application/json") ;JSON
}
...and then I'm not sure what to do.

Please could someone give me a few pointers?

Many thanks,
Matt

teadrinker
Posts: 4326
Joined: 29 Mar 2015, 09:41
Contact:

Re: Downloading JSON data from Zoom's API  Topic is solved

Post by teadrinker » 27 Sep 2021, 08:13

Hi
Try this:

Code: Select all

#SingleInstance,Force
JWT_Token:="MY JWT TOKEN - EXCLUDED HERE FOR OBVIOUS REASONS"
url := "https://api.zoom.us/v2/metrics/webinars/{webinarId}/participants"
json := API_Call("GET", url, JWT_Token)
MsgBox, % json
return

;********API call**********************
API_Call(Type, url, JWT_Token){
   Whr := ComObjCreate("WinHttp.WinHttpRequest.5.1") ;Creates COM Object
   Whr.Open(Type, url, true) ;Starts the request
   Whr.SetRequestHeader("Authorization", "Bearer " JWT_Token) ;Authorisation from a JWT token
   Whr.SetRequestHeader("Content-Type","application/json") ;JSON
   Whr.Send()
   Whr.WaitForResponse()
   status := Whr.status
   if (status != 200)
      throw "HttpRequest error, status: " . status

   Arr := Whr.responseBody
   pData := NumGet(ComObjValue(arr) + 8 + A_PtrSize)
   length := arr.MaxIndex() + 1
   Return json := StrGet(pData, length, "UTF-8")
}

Coriel-11
Posts: 45
Joined: 18 Aug 2017, 09:02

Re: Downloading JSON data from Zoom's API

Post by Coriel-11 » 27 Sep 2021, 09:51

Thank you so much for this. I've run it and it threw me out at the status ID check stage. I modified the code slightly so I could see which status code I was getting back (404) so obviously there's a problem somewhere else in the process. I'll go and work that out!

When I do get it working, where will the file save? Just in the same folder as the script?

Many, many thanks,

Matt

teadrinker
Posts: 4326
Joined: 29 Mar 2015, 09:41
Contact:

Re: Downloading JSON data from Zoom's API

Post by teadrinker » 27 Sep 2021, 10:42

Coriel-11 wrote: I've run it and it threw me out at the status ID check stage
If you are trying to use this API you are most likely using incorrect URL, looks like it should be https://api.zoom.us/v2/past_webinars/{webinarId}/participants.
Coriel-11 wrote: where will the file save?
My code saves the response in the json variable: json := API_Call("GET", url, JWT_Token), which can be saved wherever you like.

Coriel-11
Posts: 45
Joined: 18 Aug 2017, 09:02

Re: Downloading JSON data from Zoom's API

Post by Coriel-11 » 28 Sep 2021, 04:35

This is amazing. I cannot thank you enough for your help with this. I have been stumbling about in the dark for days trying to figure it out. Thank you.

Matt


Post Reply

Return to “Ask for Help (v1)”