Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3638

YouTube Data API: 'Quota Exceeded' Error Despite Not Reaching Daily Limit

$
0
0

I'm working on a Google Apps Script that uploads videos to YouTube using the YouTube Data API v3. I've encountered a quotaExceeded error when attempting to upload a video, but my quota usage shows only about 64% of the daily 10,000-unit limit.

Here's a summary of the issue:

Daily Quota: 10,000 units, with only ~6,400 used.

API Response:

{"error": {"code": 403,"message": "The request cannot be completed because you have exceeded your quota.","errors": [      {"message": "The request cannot be completed because you have exceeded your quota.","domain": "youtube.quota","reason": "quotaExceeded"      }    ]  }}

I’ve reviewed my quotas on Google Cloud Console, and they seem within limits. I also confirmed there are no spikes in the API request rate (e.g., "Queries per 100 seconds").

My questions:

Are there any hidden quotas or undocumented limitations with the YouTube Data API v3 that I might be hitting?Is there a way to monitor or optimize API usage more effectively to avoid this issue?If the issue is due to upload-specific quotas (like "uploads per day"), is there a workaround, or do I need to request a quota increase?Here’s a portion of my code where the upload process initiates (using Google Apps Script):

function initiateYouTubeUpload(fileName, title, description) {  var accessToken = getYouTubeAccessToken();  if (!accessToken) {    throw new Error('YouTube access token fetch failed');  }  var url = 'https://www.googleapis.com/upload/youtube/v3/videos?uploadType=resumable&part=snippet,status';  var metadata = {    snippet: {      title: title,      description: description,      tags: ['sample'],      categoryId: '22'    },    status: {      privacyStatus: 'private'    }  };  var options = {    method: 'post',    headers: {      Authorization: 'Bearer '+ accessToken,'Content-Type': 'application/json; charset=UTF-8','X-Upload-Content-Type': 'video/mp4'    },    payload: JSON.stringify(metadata),    muteHttpExceptions: true  };  var response = UrlFetchApp.fetch(url, options);  if (response.getResponseCode() === 200 || response.getResponseCode() === 201) {    return response.getHeaders()['Location'];  } else {    throw new Error('Failed to initiate YouTube upload: '+ response.getContentText());  }}

Viewing all articles
Browse latest Browse all 3638

Trending Articles