简体   繁体   English

远程服务器返回错误:(400)错误请求。

[英]The remote server returned an error: (400) Bad Request.

I am trying to make a facebook open graph api call from inside by web application.I am making a web request using a C# request like this. 我正试图通过Web应用程序从内部进行facebook打开图形api调用。我正在使用这样的C#请求发出Web请求。

string token = "q2Fe0utty5gzCasPL23...";
string url = "https://graph.facebook.com/me?access_token=" + 
    HttpUtility.UrlEncode(token) +"&response_type=id";

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

Stream receiveStream = response.GetResponseStream();
StreamReader readStream = newStreamReader(receiveStream,Encoding.UTF8);
string responseData = readStream.ReadToEnd();

_context.SaveChanges();

As the token has some special characters(+,/,==) in it i have encoded it using HttpUtility.UrlEncode(token) but still i get the following error. 由于令牌中有一些特殊字符(+,/,==),我使用HttpUtility.UrlEncode(令牌)对其进行编码,但仍然会出现以下错误。

The remote server returned an error: (400) Bad Request. 远程服务器返回错误:(400)错误请求。

How do i go about fixing this error. 我该如何解决此错误。 I did the above things by seeing some response in stack-overflow, but still getting the error.Where did i go wrong? 我通过在堆栈溢出中看到一些响应来做上述事情,但仍然得到错误。我哪里出错了?

As the token has some special characters(+,/,==) 因为令牌有一些特殊字符(+,/,==)

That sounds strange … usually access tokens consist of letters, numbers and maybe a pipe symbol. 这听起来很奇怪......通常访问令牌包括字母,数字和管道符号。

And if you make a request with a non-valid access token (not meaning expired, but a token that could not be decoded at all), then you'll get a 400 response. 如果您使用无效的访问令牌发出请求(不是意味着已过期,而是根本无法解码的令牌),那么您将获得400响应。

So please check your token in the debug tool, https://developers.facebook.com/tools/debug 因此,请在调试工具中检查您的令牌, https://developers.facebook.com/tools/debug

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 获取错误“远程服务器返回错误:(400)错误请求。”在线WebResponse response = request.GetResponse(); - Getting error “ The remote server returned an error: (400) Bad Request.” on line WebResponse response = request.GetResponse(); Http Web请求远程服务器返回错误:(400)错误的请求。 Twitter时间轴 - Http web request The remote server returned an error: (400) Bad Request. twitter timeline 远程服务器返回错误:(400) 错误请求。 仅在其他服务器上出错 - The remote server returned an error: (400) Bad Request. Getting error only on other servers Google日历插入事件导致“远程服务器返回错误:(400)错误的请求。”错误 - Google Calendar Inserting Event results in “The remote server returned an error: (400) Bad Request.” error 当我向Quickbooks添加新客户时,“远程服务器返回错误:(400)错误的请求。” - “remote server returned an error: (400) Bad Request.” when I am adding new Customer to Quickbooks.. 远程服务器返回错误:(400)错误的请求。 在Yahoo Oath 2.0中 - The remote server returned an error: (400) Bad Request.? in yahoo Oath 2.0 远程服务器返回错误:(400) 错误请求。 api.reseller.world - The remote server returned an error: (400) Bad Request. api.reseller.world C#WCF“ System.Net.WebException:远程服务器返回错误:(400)错误的请求。” - C# WCF “System.Net.WebException: The remote server returned an error: (400) Bad Request.” ALM Rest API:site-session返回“远程服务器返回错误:(400)错误的请求。” - ALM Rest API : site-session returns 'The remote server returned an error: (400) Bad Request.' 错误 - 远程服务器返回意外响应:(400)错误请求。 - Error-The remote server returned an unexpected response: (400) Bad Request.
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM