Hi
In below code i am getting error.
C#
Error 404 (Not Found)!!1
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
404. That’s an error.
The requested URL /v2/reports/reports?key=ApiKey was not found on this server. That’s all we know.C#
public void VideoContentDetails()
{
Int32 Count = 1;
StringBuilder htmlTable = new StringBuilder();
List listVideo = new List();
var client = new RestClient("youtubeanalytics.googleapis.com/v2/reports");
var request = new RestRequest("reports", Method.GET);
request.AddParameter("key", "ApiKey");
var response = client.Execute(request);
}Thanks

Amit MohantyRank #112 · 20K reputationPosted Feb 8, 2023, 1:29 AM EST
Try this
var client = new RestClient("https://youtubeanalytics.googleapis.com/v2/"); var request = new RestRequest("reports", Method.GET); request.AddParameter("key", "YOUR_API_KEY"); var response = client.Execute(request);Naimish MakwanaRank #324 · 7.7K reputationPosted Feb 8, 2023, 1:43 AM EST
Hello Ramco,
Try below code.
string accessToken = "YOUR_ACCESS_TOKEN"; var client = new RestClient("https://youtubeanalytics.googleapis.com/v2/reports"); var request = new RestRequest("", Method.Get); request.AddQueryParameter("ids", "channel==your_channel_id"); request.AddQueryParameter("start-date", "your_start_date"); request.AddQueryParameter("end-date", "your_end_date"); request.AddQueryParameter("metrics", "views"); request.AddQueryParameter("dimensions", "day"); request.AddHeader("Authorization", $"Bearer {accessToken}"); var response = client.Execute(request);Thanks
Naimish Makwana
Rijwan AnsariRank #82 · 24.2K reputationPosted Feb 8, 2023, 2:07 AM EST
Hi,
I think your API key is incorrect or missing scope.
Rijwan AnsariRank #82 · 24.2K reputationPosted Feb 8, 2023, 2:08 AM EST
public void VideoContentDetails() { Int32 Count = 1; StringBuilder htmlTable = new StringBuilder(); List listVideo = new List(); var client = new RestClient("youtubeanalytics.googleapis.com/v2/reports"); var request = new RestRequest("reports", Method.GET); request.AddParameter("key", "ApiKey");//replace ApiKey with actual key var response = client.Execute(request); }Replace with correct ApiKey.
Satya KarkiRank #78 · 24.6K reputationPosted Feb 8, 2023, 2:49 AM EST
Hi Ramco, check your API Key whether it is correct and try.
Sandhiya PriyaRank #26 · 43.2K reputationPosted Jan 2, 2026, 6:50 AM EST
You’re getting 404 – Not Found because the YouTube Analytics API endpoint is incorrect and incomplete in your request. The HTML you pasted is actually Google’s default 404 error page, not something caused by your C# code syntax.
Let’s break it down clearly.
The main issues in your code are:
Wrong base URL + resource combination
Missing required query parameters
YouTube Analytics API does NOT work with API key alone
1. Incorrect URL construction
You are doing this:
var client = new RestClient("youtubeanalytics.googleapis.com/v2/reports"); var request = new RestRequest("reports", Method.GET);This results in:
That URL does not exist, which is why Google returns 404.
2. Correct base URL
The correct base URL should include https and should not duplicate
reports.Correct base URL:
https://youtubeanalytics.googleapis.com/v2/3. YouTube Analytics API requires OAuth 2.0
? Important
You cannot access YouTube Analytics reports using just an API key.
The API requires:
OAuth 2.0 authentication
An access token
A valid authorized YouTube channel
So this will always fail:
request.AddParameter("key", "ApiKey");4. Required parameters for
/reportsThe
/reportsendpoint requires mandatory parameters such as:idsstartDateendDatemetricsWithout these, the request is invalid even if authentication works.
5. Correct example (URL format)
A valid request looks like this:
And it must include an OAuth Bearer token.
6. Correct RestSharp example (simplified)
var client = new RestClient("https://youtubeanalytics.googleapis.com/v2/"); var request = new RestRequest("reports", Method.GET); request.AddHeader("Authorization", "Bearer YOUR_ACCESS_TOKEN"); request.AddParameter("ids", "channel==MINE"); request.AddParameter("startDate", "2024-01-01"); request.AddParameter("endDate", "2024-01-31"); request.AddParameter("metrics", "views"); var response = client.Execute(request);7. Why LAN or browser tests may confuse you
Opening the URL directly in a browser ? returns 404
Using API key ? unauthorized for Analytics API
Missing OAuth token ? request rejected
This behavior is expected.
summary
•
/v2/reports/reportsis invalid• API key alone will not work
• Required parameters are missing
• Use correct base URL
• Authenticate using OAuth 2.0
• Pass required query parameters