Hi
I have below code to list my own videos but it is saying No Data Found. In allitems it is showing Count = 0
C#
protected void MyOwnVideos()
{
StringBuilder htmlTable = new StringBuilder();
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", "_nNoaVw");
request.AddParameter("key", "AIzaSyFG8");
List allItems = new List();
IRestResponse response = client.Execute(request);
htmlTable.Append("");
htmlTable.Append("Video IdVideo TitleDescriptionViewsLikeCommentPublished");
htmlTable.Append("");
foreach (var data in allItems.OrderBy(x => x.snippet.publishedAt))
{
}Thanks

Tuhin PaulRank #7 · 71.9K reputationPosted Feb 9, 2025, 11:21 AM EST
The issue you're encountering (
Count = 0inallItems) likely stems from one or more of the following problems:https://www.googleapis.com/youtube/v3/search, not justgoogleapis.com/youtube/v3.channelIdyou are using is correct. You can verify it by visiting your YouTube channel and checking the URL or using the API to fetch your channel details.maxResultsparameter is optional but defaults to 5. If you want more results, specify a higher value (e.g.,maxResults=50).Changed the base URL to
https://www.googleapis.com/youtube/v3.Check the
channelIdis correct. You can find it by:Check the API key is valid and has access to the YouTube Data API.
https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&channelId=UC_nNoaVw&key=YOUR_API_KEYAdded a check to ensure the response contains data before proceeding.
Fixed the loop to iterate over
response.Data.itemsinstead of an emptyallItemslist.Added
maxResults=50to fetch up to 50 videos per request.Test your API key with a simple GET request in your browser or Postman
https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&channelId=UC_nNoaVw&key=YOUR_API_KEYUse the following API endpoint to fetch your channel details and confirm the
channelId:https://www.googleapis.com/youtube/v3/channels?part=id&mine=true&key=YOUR_API_KEYLog the raw response from the API to debug any issues: