How to download a recording using C#

I’ve written some C# code to retrieve the following values using the Zoom API’s:

  • List All Users
  • List User Recordings

But I can’t seem to download recording files successfully using the WebClient C# class.
It seems to download the HTML for the Sign In page.
I’ve also tried setting the Authorization header the same way as I do to retrieve values using the Zoom API’s. But it doesn’t download any data when I set the Authorization header before trying to download the recording files.

Can someone please kindly show me a C# example on how to download Zoom recording files?

Thank you

1 Like

Hey @alan.stewart,

Are your recording files set to password protected or private in your settings?

If so you need to follow this flow:

Thanks,
Tommy

Hi Tommy

I’ve checked the settings you mentioned. The “Share cloud recordings only with members of my account” option was ON, and the other option was OFF. I’ve made sure both options are off.

Initially I was using the WebClient.DownloadFile C# method to try and download a file, with no luck. I’ve also tried to download a file using the HttpWebClient class. It threw a WebException when it called the “request.GetResponse()” method with the following exception message:

The remote server returned an error: (401) Unauthorized.

I’ve pasted the C# code I’m using below.
Do you have a C# code example on how to download recording files please?

C# Code
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);

// The Bearer property returns $“Bearer {GetAccessToken()}”
request.Headers.Add(System.Net.HttpRequestHeader.Authorization, Bearer);

byte fileData = new byte[0];

using (Stream sr = request.GetResponse().GetResponseStream())
{
using (MemoryStream ms = new System.IO.MemoryStream())
{
byte buffer = new byte[0x1000];
int bytes;
while ((bytes = sr.Read(buffer, 0, buffer.Length)) > 0)
{
ms.Write(buffer, 0, bytes);
}

    fileData = ms.ToArray();
}

}

Many thanks

Hey @alan.stewart,

As I am unfamiliar with the WebClient C# class, please reference this stack over flow answer.

Can you try going to the download_url via the browser and see if you still get the Unauthorized error?

Thanks,
Tommy

Hi Tommy
Thank you for attaching a StackOverflow link.
Using the WebClient.DownloadFile method was the first thing I tried. But when that didn’t work I thought the Token or User Credentials were required to download a file. But unfortunately, that didn’t work either.

When I try and download a file from Google Chrome using the Download URL, it works if I’ve logged into my Zoom user account on zoom.us.

But if I try and download a file from IE using the Download URL, when I haven’t logged into my Zoom user account, it displays the following message and doesn’t download the file:
Download has been disabled by the administrator (200)

Many thanks

Hey @alan.stewart,

Thanks for the details.

It sounds like the settings I mentioned above are turned on at the Admin level, hence not allowing you to download the recordings.

Make sure to match these settings at the Admin level, OR use a JWT token to download the private/password protected recordings.

46%20AM

Thanks,
Tommy