Reputation: 41
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.
Upvotes: 4
Views: 5465
Reputation: 332
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.
Upvotes: 3