我尝试发送这两个请求,但我只收到标题中列出的错误作为响应。 我对谷歌服务器的两个网络请求是这样的:
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());
我从调试器得到以下输出:
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
}
最佳答案
如果您不能使用 Google.Apis.YouTube.v3 Client Library在你的项目中,使用 lib 创建一个测试项目,做你想做的并使用 fiddler 嗅探流量
关于c# - Http 请求状态代码 405 ReasonPhrase : '' Youtube APi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32848517/