Skip to content

Instantly share code, notes, and snippets.

@eads
Created July 9, 2012 18:08
Show Gist options
  • Save eads/3077965 to your computer and use it in GitHub Desktop.
Save eads/3077965 to your computer and use it in GitHub Desktop.
Python reference script for Socrata inline query API
import requests
import json
url = "https://data.cityofchicago.org/api/views/INLINE/rows.json?method=getRows&start=0&length=10"
post = { 'originalViewId' : 'ijzp-q8t2', 'name' : 'inline filter' }
resp1 = requests.post(url, data=post) # Form encoded post payload
resp2 = requests.post(url, data=json.dumps(post)) # JSON encoded post payload
# -- Output --
# In [14]: resp1.content
# Out[14]: '{\n "code" : "invalid_request",\n "error" : true,\n "message" : "The view was not included in the post for an INLINE method call"\n}\n'
# In [15]: resp2.content
# Out[15]: '{\n "code" : "invalid_request",\n "error" : true,\n "message" : "The view was not included in the post for an INLINE method call"\n}\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment