Reputation: 1727
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.
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.
The remote server returned an error: (400) Bad Request.
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?
Upvotes: 0
Views: 7596
Reputation: 96325
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.
So please check your token in the debug tool, https://developers.facebook.com/tools/debug
Upvotes: 2