Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Http Request Status Code 405 ReasonPhrase: '' Youtube APi

I try to send this two requests but I only get as a response the errors listed in the title. My two webrequests to the google servers are like this:

HttpClient http = new HttpClient();

HttpResponseMessage response = await http.GetAsync("https://accounts.google.com/o/oauth2/token?code="+localSettings.Values["AccessKey"]+"&client_id=XX-XXXXXXXXXX.apps.googleusercontent.com&client_secret=XXXXX-XXXX&redirect_uri=http://localhost/oauth2callback&grant_type=authorization_code");

//response.EnsureSuccessStatusCode();
Debug.WriteLine(response.ToString());
HttpResponseMessage response1 = await http.GetAsync("https://content.googleapis.com/youtube/v3/subscriptions?part=id&maxResults=10&mine=true&key="+localSettings.Values["AccessKey"]);
Debug.WriteLine(response1.ToString());

I get the following output from the Debugger:

StatusCode: 405, ReasonPhrase: '', Version: 2.0, Content: System.Net.Http.StreamContent, Headers:
{
  server: GSE
  alt-svc: quic=":443"; p="1"; ma=604800
  cache-control: max-age=0, private
  accept-ranges: none
  date: Tue, 29 Sep 2015 16:05:03 GMT
  x-frame-options: SAMEORIGIN
  vary: Accept-Encoding
  x-content-type-options: nosniff
  alternate-protocol: 443:quic,p=1
  x-xss-protection: 1; mode=block
  content-type: application/json
  expires: Tue, 29 Sep 2015 16:05:03 GMT
}
StatusCode: 400, ReasonPhrase: '', Version: 2.0, Content: System.Net.Http.StreamContent, Headers:
{
  server: GSE
  alt-svc: quic=":443"; p="1"; ma=604800
  cache-control: max-age=0, private
  accept-ranges: none
  date: Tue, 29 Sep 2015 16:05:04 GMT
  x-frame-options: SAMEORIGIN
  vary: X-Origin
  vary: Origin
  vary: Accept-Encoding
  x-content-type-options: nosniff
  alternate-protocol: 443:quic,p=1
  x-xss-protection: 1; mode=block
  content-type: application/json; charset=UTF-8
  expires: Tue, 29 Sep 2015 16:05:04 GMT
}
like image 634
Matthias Herrmann Avatar asked Sep 29 '15 15:09

Matthias Herrmann


1 Answers

If you cannot use Google.Apis.YouTube.v3 Client Library in your project, create a test project with the lib, doing what do you want and sniff the traffic with fiddler

like image 138
IgorL Avatar answered Oct 18 '22 11:10

IgorL