I'm having a problem with the Facebook API.
No matter what API request I make using Postman, it returns a code of 400. But when I copy the url to the browser, it returns the result without any error.
Example:
https://graph.facebook.com/v14.0/me/friends?fields=id,name&limit=5000&access_token={token}
Related
I'm trying to replicate a post request done normally by a website form via postman but the server returns 500 error.
the form website URL that I'm dealing with is here.
what I have done so far is investigate the network request using chrome or safari dev tools, copy the request as cURL, import the cURL in postman and do the request.
what can be the possible reasons for the failure and what are the alternative ways to achieve the same result?
Postman Headers:
Most probably you must have used invalid request body. The browser shows parsed json body and you might have copied incomple request body.
To get full body click view source and copy the full content.
I am trying to create a surveymonkey webhook to receive my survey response and i am passing my SugarCRM custom entry point URL as "Subscription Url". But i am getting error " 'mycustomEntryPointUrl' did not return a success status code. Status code is 301". My Entry point is working fine if i run it in browser using its URL also my Sugar is working smoothly.
So, i just want to know any other reason which can cause this error.
Yes so HTTP status code 301 means the page has moved permanently. If you visit it in your browser, for example, you would see a network request to the page specified with a status code of 301, then a second one to the new page. Our API request won't do any redirect, so if a 301 is returned it will raise an error.
This sometimes happens when you go to a page with http and then it redirects to https due to rules on your server.
You also want to make sure your subscription URL supports a HEAD request without any redirect.
I am trying to access zomato api.
URL: https://developers.zomato.com/api/v2.1/categories
Headers: 'X-Zomato-API-Key':'myapikeyhere-763demoapi434'
If I use chrome's postman extension or curl then I can access the url & getting 200 status code.
But if I run it through my angular2 app or simple ajax, it is giving error at preflight OPTIONS request, error code is 501. I have tried otherways too, error is same. Need help
Zomato API's can only be accessed from server to server calls, the error message you have reported is a security policy implemented by Chrome to prevent cross site request forgery on the client side.
A way you can get around this is to write a handler on your server end to make handler which the ajax call will use, this handler in-turn makes a request to the Zomato's server to retrieve the data required.
I'm developing a web app that uses FB data for some FB posts. I have a bunch of post ids and am fetching the data related to them using batched requests. Then am showing a summary of each post (number of comments, shares, likes) and link to the actual FB page (https://www.facebook.com/). But clicking on the link shows a 404 page on FB!!
Example, the node_id, '69983322463_10152179775342464' will return data in the graph explorer. But when you access https://www.facebook.com/69983322463_10152179775342464 it returns 404!
In case my question is not clear:
GET https://graph.facebook.com/69983322463_10152179775342464?access_token={a valid access token} returns data.
But GET https://www.facebook.com/69983322463_10152179775342464 (with or without an access_token param) returns a 404
Is there some field in the API response that signifies that the page does not exist anymore?
Thanks,
mano
This is because not every post is public. Only publicly available posts can be accessed directly.
For rest you need a valid access token to GET its details. When you tried the post id in graph api explorer it showed the result since an access token was applied.
So, you simply use a valid access token, may be any app access token (app_id|app_secret)- that never expires, and make the /GET request.
Eg: \GET /69983322463_10152179775342464?access_token={app-access-token}
In my index page, I have this link for me to auth with the facebook.
Test
Inside my TestServlet, it will auth and get the access token for me to query the graph api. I will query and store the info into a list of 200 results. The results are forward to my jsp page (test.jsp).
Inside my test.jsp:
URL will show http://xxx.herokuapp.com/test?code=xxx
As I don't wish to display all 200 results at the same time, I only load 20 results at a time. I have a link to the next page <a href='/test?page=${page+1}&code=${code}'>Next Page</a> where the page is the current page number 1 and code is the code on the url.
However, I will hit this error when I clicked the 'Next Page' link:
java.io.IOException: Server returned HTTP response code: 400 for URL: https://graph.facebook.com/oauth/access_token?client_id=xxx&redirect_uri=http://xxx.herokuapp.com/test&client_secret=xxx&code=xxx
Does the problem lies in encoding issue? If so, how should I encode the code in the url and where should I encode it? Inside my jsp page or servlet? Thanks.
Looks like you are trying to get access_token again using the same "code" in your "next page" link. And Facebook is returning 400 bad request error. The "code" returned by facebook is supposed to be used just once to get the access_token. And once you have access token, use that for all further Graph API calls.
If you are using sessions, you can store the access_token in session and use that for Graph API calls. Otherwise, you can pass the access_token (instead of code) in the next page link:
<a href='/test?page=${page+1}&access_token=${access_token}'>Next Page</a>