Hi
I am getting error - {
"error": {
"code": 403,
"message": "The request cannot be completed because you have exceeded your \u003ca hef=\"/youtube/v3/getting-started#quota\"\u003equota\u003c/a\u003e.",
"errors": [
{
"message": "The request cannot be completed because you have exceeded your \u003ca hef=\"/youtube/v3/getting-started#quota\"\u003equota\u003c/a\u003e.",
"domain": "youtube.quota",
"reason": "quotaExceeded"
}
]
}
}
In below code it is showing Null value.
tagResponse.Data.items
protected void MyOwnVideos11()
{
StringBuilder htmlTable = new StringBuilder();
string nextPageToken = string.Empty;
Int32 Sr = 1;
var data0 = GetVideosList(nextPageToken);
var orderByPublishAt = data0.items.OrderBy(x => x.snippet.publishedAt);
htmlTable.Append("");
htmlTable.Append("Sr. Video Title Description Views Like Comment Published ");
htmlTable.Append("");
nextPageToken = data0.nextPageToken;
while (!string.IsNullOrEmpty(nextPageToken))
{
data0 = GetVideosList(nextPageToken);
orderByPublishAt = data0.items.OrderBy(x => x.snippet.publishedAt);
nextPageToken = data0.nextPageToken;
foreach (var data in orderByPublishAt)
{
var clientTag = new RestClient("googleapis.com/youtube/v3/");
var tagRequest = new RestRequest("videos", Method.GET);
tagRequest.AddParameter("key", "AIzaG8");
tagRequest.AddParameter("part", "snippet,statistics");
tagRequest.AddParameter("id", data.id.videoId);
var tagResponse = clientTag.Execute(tagRequest);
foreach (var item in tagResponse.Data.items)
{
htmlTable.Append("" + Sr + " ");
htmlTable.Append(" ");
htmlTable.Append("" + item.snippet.title + " ");
htmlTable.Append("" + item.snippet.description + " ");
htmlTable.Append("" + item.statistics.viewCount + " ");
htmlTable.Append("" + item.statistics.likeCount + " ");
htmlTable.Append("" + item.statistics.commentCount + " ");
htmlTable.Append("" + data.snippet.publishedAt.ToString("dd-MM-yyyy") + " ");
htmlTable.Append("");
Sr = Sr + 1;
}
}
}
htmlTable.Append(" ");
htmlTable.Append("
");
PlaceHolderTable.Controls.Add(new Literal { Text = htmlTable.ToString() });
}
private static YoutubeSearchListResponse GetVideosList(string nextPageToken)
{
var client = new RestClient("googleapis.com/youtube/v3");
var request = new RestRequest("search", Method.GET);
request.AddParameter("part", "snippet");
request.AddParameter("type", "video");
request.AddParameter("channelId", "UoaVw");
request.AddParameter("key", "AIzaG8");
if (!string.IsNullOrEmpty(nextPageToken))
{
request.AddParameter("pageToken", nextPageToken);
}
var response = client.Execute(request);
return response.Data;
}
Thanks
John GodelPosted Apr 4, 2025, 7:36 PM
You're getting a 403
quotaExceedederror from the YouTube Data API, and then getting a null response (tagResponse.Data.items) — both are related. Let's fix this step-by-step and make your code more robust.Root Cause of the Error
The error:
"The request cannot be completed because you have exceeded your quota."means your YouTube Data API daily quota has been used up. Each API call consumes quota units, and you’ve likely hit the daily limit (default is 10,000 units/day unless raised).