Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RestSharp "Not found" response

I'm trying to use the Youtube Data API v3 with RestSharp. Problem is: I get the response: "Not found" when I try to send a request.

var client = new RestClient("https://www.googleapis.com/youtube/v3/channels?part=statistics");

var request = new RestRequest(Method.POST);
request.AddParameter("key", my api key);
request.AddParameter("id", my channel id);
request.AddParameter("fields", "items/statistics/subscriberCount");

IRestResponse response = client.Execute(request);
var content = response.Content;

Console.WriteLine(response.Content);
this.BeginInvoke((System.Windows.Forms.MethodInvoker)delegate () { label1.Text = response.Content; });

This seems to be a problem with RestSharp or the code because in the Google API explorer thing you can test out the inputs and it works there.

like image 505
Neo Mossbäck Avatar asked Sep 03 '25 08:09

Neo Mossbäck


1 Answers

I was trying the same thing today and was stuck on the same step. With an hour of effort I figured out.

In the RestClient(baseUri) constructor, just pass the base url and not the whole path.

While initializing RestClient(resource, Method), pass the path as resource and method will be the second parameter.

like image 107
akisonlyforu Avatar answered Sep 04 '25 22:09

akisonlyforu