AnsweredAssumed Answered

Python script to consume JSON web service to file geodatabase

Question asked by Geoffrey.West on Jan 28, 2015
Latest reply on Jan 28, 2015 by xander_bakker

I am working on a proof of concept for a larger project and am sure this has been done and is possible, however I cannot find any examples anywhere.  I would like to use my own ArcGIS Feature Service as an example where I use a Python script to parse fields that I would like to keep and print and all geometries.  I can handle to print portion to CSV, then table to table conversion.  The block below works fine in printing the feature service info.  Later, I would like to use UPDATE to apply changes made in a web service directly to our feature service.

 

import json
import urllib2

url = 'url'
r = urllib2.urlopen(url)
data = json.loads(r.read().decode(r.info().getparam('charset') or 'utf-8'))
print data

 

Prints:

{u'maxRecordCount': 1000, u'layers': [{u'id': 0, u'name': u'ServiceRequest.DBO.ServiceTypeDevSchema'}], u'allowGeometryUpdates': True, u'supportsDisconnectedEditing': False, u'description': u'', u'tables': [{u'id': 1, u'name': u'ServiceRequest.DBO.queryTable'}, {u'id': 2, u'name': u'ServiceRequest.DBO.queryTableLocation'}], u'initialExtent': {u'xmin': -118.79175291224679, u'ymin': 34.0096898681482, u'ymax': 34.27571360860003, u'xmax': -118.36725706880667, u'spatialReference': {u'wkid': 4326, u'latestWkid': 4326}}, u'documentInfo': {u'Category': u'', u'Author': u'', u'Title': u'', u'Comments': u'', u'Keywords': u'', u'Subject': u''}, u'capabilities': u'Create,Delete,Query,Update,Uploads,Editing', u'copyrightText': u'', u'units': u'esriDecimalDegrees', u'currentVersion': 10.21, u'enableZDefaults': False, u'hasVersionedData': False, u'spatialReference': {u'wkid': 4326, u'latestWkid': 4326}, u'fullExtent': {u'xmin': -118.54056884699997, u'ymin': 33.941116961000034, u'ymax': 34.222864945000026, u'xmax': -118.23978848099995, u'spatialReference': {u'wkid': 4326, u'latestWkid': 4326}}, u'syncEnabled': False, u'serviceDescription': u'', u'supportedQueryFormats': u'JSON, AMF'}

Outcomes