urlfetch.fetch reporting inconsistent results?

97 views
Skip to first unread message

Diego Marchi

unread,
Mar 17, 2016, 2:26:13 PM3/17/16
to Google App Engine

urlfetch.fetch is reporting inconsistent results when querying the facebook graph api. If I curl the same URL from my terminal, it works fine. It works ok also using the local instance of the GAE with dev_appserver.py.

I am using a mac and the dev_appserver version on my local is 1.9.20. I am using Python.

I cannot share the access token, but the url I am trying to reach is "https://graph.facebook.com/v2.3/184277601936688" - from the remote instance I saw the logs reporting this:
{
   "error": {
      "message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
      "type": "GraphMethodException",
      "code": 100,
      "fbtrace_id": "He4bs+MI7Qs"
   }
}

but with curl and also on my local instance, I get a proper response and a JSON document.

anybody has any advice on this? I received an email yesterday from google, stating that url_fetch has some inconsistend behaviour and I believe I stumbled in it. They say to contact their support in this case but where can I reach them?

Thanks

Luciano Pacheco

unread,
Mar 18, 2016, 1:09:26 AM3/18/16
to Google App Engine
Hello Diego,

I'm Luciano from Google Cloud Support.

The issue mentioned on the email you that received yesterday has been fixed. So the error you're experiencing is unrelated.

I searched online for "facebook graphapi GraphMethodException" and it seems related to some permissions on the Facebook app or entity being updated, see this stackoverflow question for example.

I also suggest you to upgrade your local environment from 1.9.20 to our latest version 1.9.34.

Cheers,

Luciano Pacheco

Diego Marchi

unread,
Mar 23, 2016, 1:06:33 PM3/23/16
to Google App Engine
Hello Luciano,

thanks for your answer. As you suggested I've upgraded my local dev_appserver version to 1.9.34.

GraphMethodException is related to a search that cannot be served by the Graph API since there is no handler for it. I don't think this is the case since, as mentioned, I can access the same url I query from the GAE instance, using CURL and in that case I obtain a valid result and not an exception. 
It works also on my local instance, when I use the interactive console and use urlfetch.fetch. It also works when I fetch the sm API url from inside my program on my local machine.

Summarizing:
- from terminal: 

- from local instance:
from google.appengine.api import urlfetch


u
= urlfetch.fetch("https://graph.facebook.com/v2.3/184277601936688?access_token=xxxxxxxxxxx")
print u.content
WORKS

- from local instance program runs and visits API endpoint: WORKS

- from GAE remote instance
from google.appengine.api import urlfetch

u
= urlfetch.fetch("https://graph.facebook.com/v2.3/184277601936688?access_token=xxxxxxxxx")

print u.content
DOES NOT WORK

- from remote instance program runs and visits API endpoint: DOES NOT WORK 

At the present time, I cannot find the problem. I thought it could be that facebook just cut off requests coming from GAE or certain ips... but it does NOT happen for all the facebook ids I try to query, only for some of them.

Joshua Johnston

unread,
Mar 23, 2016, 3:21:23 PM3/23/16
to Google App Engine
See http://stackoverflow.com/questions/6843796/graph-api-returns-false-or-unsupported-get-request-accessing-public-facebook and http://stackoverflow.com/questions/13739609/unsupported-get-request-in-facebook-graph-api on stack overflow.

It may be restrictions set on the page around Country / Age / Page Visibility. It may also be because the page does not have enough likes yet (< 25)

Kaan Soral

unread,
Mar 23, 2016, 3:47:45 PM3/23/16
to Google App Engine
As a very sincere suggestion, try not to build anything for fb at all, if you can (and for instagram/twitter for that matter)

It's basically a trap for developers, you waste your resources (i), there is no positive outcome at all, even if you manage to get a positive outcome, it will be terminated with various excuses and sometimes no excuses at all

More on topic, unexplainable fb api failures are pretty common, I just ignore them at this point, try not to lose time on it, if it's not mission critical, in some months, it may even fix itself, even if you report it to fb and it gets accepted as a bug, don't expect a swift solution (because (i))

The only valid fb api usage at this point is b2b apps, where the end-business is the ones that are trapped, like page owners etc., you might profit from selling apps to them while their waste their times with their fb pages, even in this case, if you are not at the point of no return, return and do something useful :)

Diego Marchi

unread,
Mar 28, 2016, 2:31:20 PM3/28/16
to Google App Engine
I don't think it's something that has to do with that kind of restrictions. I can get the response just fine using my local machine or any other machine.

If the graph api is the culprit then it's because it's limiting the access to GAE perhaps, but that would not explain why it works for most pages and not for others.

Diego Marchi

unread,
Mar 28, 2016, 2:32:05 PM3/28/16
to Google App Engine
Unfortunately this is not an option :(
Reply all
Reply to author
Forward
0 new messages