Select to view content in your preferred language

How to reference related tables in URL call in this python script?

3149
1
01-27-2016 02:13 PM
JinsongQiu
New Contributor

This script works great to download AGOL features and attachments. Thank you. However, the same code doesn't work on related tables and attachments.

Python script to pull hosted features with attachments into a local file geodatabase. See ReadMe bel...

The data URLs are,

http://services.arcgis.com/xyz123456orgid/arcgis/rest/services/myFeatures/FeatureServer/0 (main feature class)

http://services.arcgis.com/xyz123456orgid/arcgis/rest/services/myFeatures/FeatureServer/1 (related table 1)

http://services.arcgis.com/xyz123456orgid/arcgis/rest/services/myFeatures/FeatureServer/2 (related table 2)

It doesn't work by changing

  crUrl = 'http://...FeatureServer/1/..' or

  crValues={... 'layers': '1', ...}

The original Code as,

crUrl = 'http://services.arcgis.com/xyz123456orgid/arcgis/rest/services/myFeatures/FeatureServer/CreateReplic...'

crValues = {'f' : 'json',

'layers' : '0',

'returnAttachments' : 'true',

'token' : token }

crData = urllib.urlencode(crValues)

crRequest = urllib2.Request(crUrl, crData)

crResponse = urllib2.urlopen(crRequest)

crJson = json.load(crResponse)

replicaUrl = crJson['URL']

urllib.urlretrieve(replicaUrl, 'myLayer.json')

###########

Please help. How to reference related tables in URL call in this script?

0 Kudos
1 Reply
JinsongQiu
New Contributor

The problem is resolved, by using layers=[0,1,2,3]. ArcREST/create_replica_fs.py at master · Esri/ArcREST · GitHub

0 Kudos