facebook-insights icon indicating copy to clipboard operation
facebook-insights copied to clipboard

KeyError: 'type' -> --> 302 self.type = raw['type'] in graph.pyc

Open jcwelty opened this issue 6 years ago • 2 comments


KeyError Traceback (most recent call last) in () ----> 1 latest = page.posts.latest(20).get()

C:\ProgramData\Anaconda2\lib\site-packages\facebookinsights-0.3.4-py2.7.egg\facebookinsights\graph.pyc in get(self) 81 for page in pages: 82 for post in page['data']: ---> 83 post = Post(self.edge, post) 84 85 # For date ranges, we can't rely on pagination

C:\ProgramData\Anaconda2\lib\site-packages\facebookinsights-0.3.4-py2.7.egg\facebookinsights\graph.pyc in init(self, page, raw) 300 self.graph = page.graph.partial(raw['id']) 301 self.id = raw['id'] --> 302 self.type = raw['type'] 303 self.created_time = utils.date.parse(raw['created_time']) 304 self.updated_time = utils.date.parse(raw['updated_time'])

KeyError: 'type'

Any ideas? Did something change with in the Graph API

jcwelty avatar Mar 06 '18 02:03 jcwelty

Yes, seems to me it did. So the code is assuming updated_time exist on raw array, when it doesn't. What I did was changing line to self.type = raw.get('type') on graph.py and the error doesn't happen. Btw, it's the same if I comment the line. I also had to do same thing for the line self.updated_time = raw.get('updated_time')

cornelyus avatar Sep 25 '18 11:09 cornelyus

Type is deprecated since v3.3 of the graph API. There is a field called status_type with similar information.

I reckon a PR to just remove it should be welcome (not that I manage this).

Donkeyfish87 avatar Nov 25 '19 14:11 Donkeyfish87