AnsweredAssumed Answered

urlencode list of dictionaries for applyEdits REST API

Question asked by dbecker88 on Jan 19, 2018
Latest reply on Jan 19, 2018 by dbecker88

featureList = [

   {

      'geometry': { 'y': 40.81670805699997, 'x': -96.71105736099997 },

      'attributes': { 'already_emailed': 'YES', 'objectid': 1, 'globalid': '{EEF86AC0-5B54-47E0-BFC8-496D457A6249}' }

   },

   {

      'geometry': { 'y': 40.816795984000066, 'x': -96.71107804500002 },

      'attributes': { 'already_emailed': 'YES', 'objectid': 2, 'globalid': '{723F5F66-98EE-4FE4-9075-31A476C60363}' }

    }

]

I have the above list of dictionaries. I'm trying to update these 2 features using the REST API, applyEdits.

I pasted the exact same list into the /applyEdits GUI on the REST endpoint and it was successful.

 

Here's the error the server is throwing, related to the brackets around globalid val.

 

Expected a ',' or '}' at character 138 of [{'geometry': {u'y': 40.81670805699997, u'x': -96.71105736099997}, 'attributes': {'already_emailed': 'YES', 'objectid': 1, 'globalid': u'{EEF86AC0-5B54-47E0-BFC8-496D457A6249}'}}, {'geometry': {u'y': 40.816795984000066, u'x': -96.71107804500002}, 'attributes':

 

Here's the method I'm using to urlencode

payload = {'updates': featureList,
                'token': accessToken,
               'useGlobalIds': 'true',
               'f': 'json'}
query_string = urllib.urlencode(payload)

req = urllib2.Request(url,query_string)

resp = urllib2.urlopen(req)

 

can someone help me urlencode that list of dictionaries?

 

thanks!

Outcomes