This script works great to download AGOL features and attachments. Thank you. However, the same code doesn't work on related tables and attachments.
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,
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?
The problem is resolved, by using layers=[0,1,2,3]. ArcREST/create_replica_fs.py at master · Esri/ArcREST · GitHub