Skip to content

Instantly share code, notes, and snippets.

@fawcett
Created January 12, 2015 15:15
Show Gist options
  • Save fawcett/65b0ce0325165ff6785d to your computer and use it in GitHub Desktop.
Save fawcett/65b0ce0325165ff6785d to your computer and use it in GitHub Desktop.
Post Problems
# You can see the results of the requests at requestb.in
# The older request fails and the newer request works (when sent to geocoder)
# http://requestb.in/x90623x9?inspect
#This data payload does not work
addrPayload = {"records": [{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}}]}
#this data payload does work
addrPayload = {"records": [{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}},{"attributes": {"STREET": "360 Sherman St Ste 300", "ZIP": "55102", "OBJECTID": 468}}]}
# function doing request
def geocodeAddressEsriRest(addressPkg,geocoderUri):
payload = json.dumps(addressPkg)
r = requests.post(geocoderUri, params={"addresses":payload, "f":"json", "outSR":4326})
return json.loads(r.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment