Hi
I have given below code for most popular. If i want to give most viewd , what changes i need to do
C#
var searchRequest = yt.Videos.List("snippet");
searchRequest.Chart = VideosResource.ListRequest.ChartEnum.MostPopular;Thanks
Hi
I have given below code for most popular. If i want to give most viewd , what changes i need to do
var searchRequest = yt.Videos.List("snippet");
searchRequest.Chart = VideosResource.ListRequest.ChartEnum.MostPopular;Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Deepak TewatiaRank #142 · 16K reputationPosted Dec 17, 2022, 2:47 PM EST
Hi Ramco,
This will retrieve a list of the most viewed videos on YouTube.
var searchRequest = yt.Videos.List("snippet"); searchRequest.Chart = VideosResource.ListRequest.ChartEnum.MostViewed;Ramco RamcoRank #462 · 5.4K reputationPosted Dec 19, 2022, 12:19 AM EST
Hi Deepak
It is giving message - VideosResource.ListRequest.ChartEnum does not containa definition for MostViewed.
Thanks
Deepak TewatiaRank #142 · 16K reputationPosted Dec 19, 2022, 12:29 AM EST
Hi Ramco,
Good morning !
This error message suggests that the ChartEnum enumeration does not include a value for MostViewed.
To get the most viewed videos, please try the below code to retrieve the videos based on view count.
This will retrieve the videos in descending order of view count, with the videos with the highest view count appearing first.
Thanks
Ramco RamcoRank #462 · 5.4K reputationPosted Dec 19, 2022, 7:54 AM EST
Hi
I am trying like below but it is giving error . Oder does not exist in the current context.
using (var yt = new YouTubeService(new BaseClientService.Initializer()
{
ApiKey = "ApiKey",
}))
{
StringBuilder htmlTable = new StringBuilder();
var request = yt.Videos.List("snippet");
request.order = SearchResource.ListRequest.OrderEnum.ViewCount;
Thanks