# Error: The remote server returned an error: (401) Unauthorized

**URL:** <https://devforum.zoom.us/t/error-the-remote-server-returned-an-error-401-unauthorized/129168>\
**Category:** Meetings\
**Created:** [March 4, 2025, 7:56am UTC](https://devforum.zoom.us/t/error-the-remote-server-returned-an-error-401-unauthorized/129168 "2025-03-04T07:56:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![scdlzoom.sisteam](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@scdlzoom.sisteam](https://devforum.zoom.us/u/scdlzoom.sisteam)\
**Post date:** [March 4, 2025, 7:56am UTC](https://devforum.zoom.us/t/error-the-remote-server-returned-an-error-401-unauthorized/129168/1 "2025-03-04T07:56:58Z")

</div>

### Before Creating a New Topic:

_If you’re experiencing unexpected API/Zoom API Events (webhooks) behavior please search the forum with relevant keywords (e.x. error message) and follow the guidance outlined in those posts. Please also leverage the following support links:_

- Zoom Developer Changelog for Dev Product Changes: [https://marketplace.zoom.us/docs/guides/stay-up-to-date/changelog/](https://marketplace.zoom.us/docs/guides/stay-up-to-date/changelog/)
- General Troubleshooting: [Support](https://devsupport.zoom.us/hc/en-us)
- To Submit a Ticket for Unexpected API/Zoom API Events Behavior: [Official Zoom Support | Help Center](https://support.zoom.us/hc/en-us)
- For General & Integrations Related Guidance: [https://community.zoom.com/](https://community.zoom.com/)
- For Troubleshooting Webhooks: [Guide: "We Are Not Receiving Webhooks As Expected" -- Here's What to Do! - #2](https://devforum.zoom.us/t/we-are-not-receiving-webhooks-as-expected-heres-what-to-do/64846/2)

* * *

### Format Your New Topic as Follows:

**API Endpoint(s) and/or Zoom API Event(s)**  
_Link the API endpoint(s) and/orZoom API Event(s) you’re working with to help give context._

**Description**  
_Details on your question, workflow or the problem you’re trying to solve._

**Error?**  
_The full error message or issue you are running into, where applicable._

**How To Reproduce**  
_Steps to reproduce the behavior:_  
_1. Request URL / Headers **(without credentials or sensitive info like emails, uuid, etc.)** / Body_  
_2. Authentication method or app type_  
_3. Any errors_

When I am trying to get VC recording from API [https://api.zoom.us/v2/meetings/](https://api.zoom.us/v2/meetings/)" + MeetingId.ToString() + "/recordings

---

<div class="post-metadata">

**Author:** ![alexm](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/alexm/32/67701_2.png) [@alexm](https://devforum.zoom.us/u/alexm)\
**Post date:** [March 7, 2025, 11:03pm UTC](https://devforum.zoom.us/t/error-the-remote-server-returned-an-error-401-unauthorized/129168/2 "2025-03-07T23:03:57Z")

</div>

@scdlzoom.sisteam please see my replies in this thread:

> [@Error code=401 when create a meeting using Java API call](https://devforum.zoom.us/t/error-code-401-when-create-a-meeting-using-java-api-call/129408/2):
>
> Hi @Glenn1, welcome to the forum! An HTTPS Error 401 indicates to me that your auth header is incorrect. Looking at this line: In my application, the grant\_type I’m using is account\_credentials not client\_credentials, so give that a shot. EDIT: Just to add, I’m also specifying my account ID in the request, which I don’t see in yours: oauth/token?grant\_type=account\_credentials&account\_id=${MY\_ZOOM\_ACCOUNT\_ID}

---

<div class="post-metadata">

**Author:** ![scdlzoom.sisteam](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@scdlzoom.sisteam](https://devforum.zoom.us/u/scdlzoom.sisteam)\
**Post date:** [March 8, 2025, 9:07am UTC](https://devforum.zoom.us/t/error-the-remote-server-returned-an-error-401-unauthorized/129168/3 "2025-03-08T09:07:50Z")

</div>

After replacing client\_credentials with account\_credentials I was getting Bad request.

---

<div class="post-metadata">

**Author:** ![alexm](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/alexm/32/67701_2.png) [@alexm](https://devforum.zoom.us/u/alexm)\
**Post date:** [March 8, 2025, 1:35pm UTC](https://devforum.zoom.us/t/error-the-remote-server-returned-an-error-401-unauthorized/129168/4 "2025-03-08T13:35:52Z")

</div>

I’d recommend posting your actual code you’re using to generate token and the request itself, with your secret stuff like account ID and secret key edited out, so we can better assist you. Thanks!

---

<div class="post-metadata">

**Author:** ![alexm](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/alexm/32/67701_2.png) [@alexm](https://devforum.zoom.us/u/alexm)\
**Post date:** [March 9, 2025, 4:25am UTC](https://devforum.zoom.us/t/error-the-remote-server-returned-an-error-401-unauthorized/129168/5 "2025-03-09T04:25:08Z")

</div>

Follow up: I’d just take a quick look at [this doc](https://developers.zoom.us/docs/api/meetings/#tag/cloud-recording/GET/meetings/%7BmeetingId%7D/recordings) and make sure your app has the required granular scopes. Also, I see that Error 400 (what you’re recieving) can in some cases have a Zoom error code, which indicates the owner of the recording isn’t part of your overall Zoom account. If that’s not the case then it’s likely your actual GET request is malformed in some way. Pasting your code and detailed error recieved is the best way to get a fix in place.

---

<div class="post-metadata">

**Author:** ![scdlzoom.sisteam](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@scdlzoom.sisteam](https://devforum.zoom.us/u/scdlzoom.sisteam)\
**Post date:** [March 10, 2025, 5:38am UTC](https://devforum.zoom.us/t/error-the-remote-server-returned-an-error-401-unauthorized/129168/6 "2025-03-10T05:38:22Z")

</div>

Thank you for your reply. Now I am getting error ‘Error: The remote server returned an error: (404) Not Found.’ Sample code attached.

using System;  
using System.Collections.Generic;  
using System.Data.SqlClient;  
using [System.IO](http://System.IO);  
using [System.Net](http://System.Net);  
using System.Net.Http;  
using System.Net.Http.Headers;  
using System.Text;  
using System.Threading.Tasks;  
using Newtonsoft.Json;  
using Newtonsoft.Json.Linq;

namespace ZoomRecording  
{  
public partial class Recordings : System.Web.UI.Page  
{

private readonly string \_clientId = “”;  
private readonly string \_clientSecret = “”;

```
    private readonly string _accountid = "";
    private readonly string _zoomApiUrl1 = "https://api.zoom.us/v2";

    private readonly string _zoomApiUrl = "https://api.zoom.us";
    private readonly string _connectionString = "Initial Catalog=SAE;Data Source=1.1.1.1;User Id=sa;Password=123456789;Connection Timeout=60"; // Database connection string
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected async void btnProcessRecordings_Click(object sender, EventArgs e)
    {
        try
        {
            string accessToken = await GetZoomAccessToken();
            if (string.IsNullOrEmpty(accessToken))
            {
                lblStatus.Text = "Failed to retrieve token.";
                return;
            }

            List<string> zoomIds = GetZoomIdsFromDatabase(); // Retrieve Zoom IDs from the database
            if (zoomIds.Count == 0)
            {
                lblStatus.Text = "No Zoom IDs found in the database.";
                return;
            }

            foreach (string zoomId in zoomIds)
            {
                //await ProcessRecording(zoomId, accessToken);
                ProcessRecording(zoomId, accessToken);
            }

            lblStatus.Text = "Recording processing completed.";
        }
        catch (Exception ex)
        {
            lblStatus.Text = "Error: " + ex.Message;
        }
    }
    private void ProcessRecording(string zoomId, string accessToken)
    {
        HttpWebRequest httpWReq = (HttpWebRequest)WebRequest.Create("https://api.zoom.us/v2/meetings/" + zoomId.ToString() + "/recordings");
        httpWReq.Method = "GET";
        httpWReq.ContentType = "application/json";
        httpWReq.Headers.Add("Authorization", String.Format("Bearer {0}", accessToken));
        HttpWebResponse response = (HttpWebResponse)httpWReq.GetResponse();
        HttpStatusCode statusCode = response.StatusCode;
        int numericStatusCode = (int)statusCode;

        string s = response.ToString();
        StreamReader reader = new StreamReader(response.GetResponseStream());
        String jsonresponse = "";
        String temp = null;
        while ((temp = reader.ReadLine()) != null)
        {
            jsonresponse += temp;
        }

        var jsonObject = JObject.Parse(jsonresponse);
        string responce = "";

        JsonResponse_RecordingVC clsobj = jsonObject.ToObject<JsonResponse_RecordingVC>();
        int cnt = 0;
        foreach (clsJsonRecording_files recordOj in clsobj.recording_files)
        {
            if (cnt == 0)
            {
                if (recordOj.play_url != "")
                {
                    if (recordOj.recording_type == "shared_screen_with_speaker_view" || recordOj.recording_type == "shared_screen_with_speaker_view(CC)")
                    {
                        responce = recordOj.play_url;
                        UpdateDatabaseWithDownloadUrl(zoomId, responce);
                        cnt = 1;
                    }
                }
            }
        }

        //return responce;
    }
    private async Task<string> GetZoomAccessToken()
    {
        using (var httpClient = new HttpClient())
        {
            var authString = $"{_clientId}:{_clientSecret}";
            var encodedAuth = Convert.ToBase64String(Encoding.UTF8.GetBytes(authString));

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", encodedAuth);

            

            var content = new FormUrlEncodedContent(new[]

                  {

                new KeyValuePair<string, string>("grant_type", "account_credentials"),

                new KeyValuePair<string, string>("client_id", _clientId),

                new KeyValuePair<string, string>("client_secret", _clientSecret),

             new KeyValuePair<string, string>("account_id", _accountid)

            });

            try
            {
                var response = await httpClient.PostAsync($"{_zoomApiUrl}/oauth/token", content);
                response.EnsureSuccessStatusCode();

                var responseContent = await response.Content.ReadAsStringAsync();
                dynamic tokenData = JsonConvert.DeserializeObject(responseContent);

                return tokenData.access_token;
            }
            catch (HttpRequestException ex)
            {
                lblStatus.Text = $"<br>Token retrieval error: {ex.Message}";
                return null;
            }
        }
    }
    private List<string> GetZoomIdsFromDatabase()
    {
        List<string> zoomIds = new List<string>();

        using (SqlConnection connection = new SqlConnection(_connectionString))
        {
         
            string query = "SELECT ZoomId,VCID FROM table WHERE RecordedURL IS NULL and ZoomId is not NULL and Isnull(VCCancel,0)=0 and Year(date)=2025 and date<='2025-03-10'"; // Replace with your table and column names
            SqlCommand command = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                zoomIds.Add(reader["ZoomId"].ToString());
            }

            reader.Close();
        }

        return zoomIds;
    }

    private void UpdateDatabaseWithDownloadUrl(string zoomId, string downloadUrl)
    {
        using (SqlConnection connection = new SqlConnection(_connectionString))
        {
           
            string query = "UPDATE table SET NWDownloadURL = @DownloadUrl WHERE ZoomId = @ZoomId"; // Replace with your table and column names

            SqlCommand command = new SqlCommand(query, connection);
            command.Parameters.AddWithValue("@DownloadUrl", downloadUrl);
            command.Parameters.AddWithValue("@ZoomId", zoomId);

            connection.Open();
            command.ExecuteNonQuery();
        }
    }
}

```

}  
class JsonResponse\_RecordingVC1  
{  
public string uuid { get; set; }  
public string id { get; set; }  
public string account\_id { get; set; }  
public string host\_id { get; set; }  
public string topic { get; set; }  
public Int16 type { get; set; }  
public string start\_time { get; set; }  
public string timezone { get; set; }

```
    public string host_email { get; set; }
    public Int16 duration { get; set; }
    public Int64 total_size { get; set; }
    public Int16 recording_count { get; set; }

    public string share_url { get; set; }

    public List<clsJsonRecording_files1> recording_files { get; set; }

    public string password { get; set; }
}
public class clsJsonRecording_files1
{
    public string id { get; set; }
    public string meeting_id { get; set; }
    public string recording_start { get; set; }
    public string recording_end { get; set; }
    public string file_type { get; set; }
    public string file_extension { get; set; }
    public Int64 file_size { get; set; }
    public string play_url { get; set; }
    public string download_url { get; set; }
    public string status { get; set; }
    public string recording_type { get; set; }

    
}

```
