xmunoz/sodapy

Exception: Unknown response format: application/json

alex-wap opened this issue · 8 comments

I deployed an application three months ago using sodapy. It was fully functional up until Monday, November 28. On my deployed instance, I get "502 Bad Gateway". Running locally, I get the following error:

File "/Users/File/Path/Crime.py", line 12, in get_crimes
crimes = client.get("cuks-n6tp",limit=3000)

File "/usr/local/lib/python2.7/site-packages/sodapy/__init__.py", line 237, in get
params=params)

File "/usr/local/lib/python2.7/site-packages/sodapy/__init__.py", line 368, in _perform_request
.format(content_type))

Exception: Unknown response format: application/json

I don't understand the exception. The data set is here and clearly json: https://data.sfgov.org/resource/cuks-n6tp.json

Let me know if this is the wrong place to post this question.

Thanks,
Alex

I modified my _ _ init _ _.py. I edited line 354: if re.match(r'application\/json;\s*charset=utf-8', content_type) or re.match(r'application\/json', content_type):

This works for my application. The regex for json: re.match(r'application\/json;\s*charset=utf-8', content_type): on line 354 does not match application/json. Maybe my data source changed its header? Should the regex match json without charset specified?

Thanks for reading.

What version of python are you using? It may not be related, but I had to upgrade python in order to meet Socrata's new security requirements.

Hey, yeah I agree that this regex could definitely be more flexible with what it matches. I'll push an update for that soon.

Gah, referenced wrong issue number in commit message. Anyway, 48634ac.

@timwis I'm using Python 2.7.6. Thanks for the link, I'll have to upgrade.

@xmunoz Thanks for the speedy fix!

Just ran into this as well, seems Socrata may have updated the content-type headers for a bunch of datasets around 11/28 midnight UTC. Awesome to see there's already a fix, thanks @xmunoz!

Thank you everybody for the bug reporting and the thanks! I came for the data, but stayed for the amazingly supportive Socrata open source dev community 🍾.