ERROR
In ArcMap, running a Python script to access the attribute table from a map service added from ArcGIS Server returns the following error:
Error: Cannot open table for Load

The error occurs because map services are used to access the attribute table. Map services do not allow access to data and are used to display representation of the map.
Note: However, the feature service can only be edited if the owner of the feature service allows editing. For more information, refer to Feature service permissions and editor tracking.
Note: The query can only be run if the feature service has a query supported operation. For more information, refer to ArcGIS REST API: Query (Map Service\ Layer).
#import the required modules
import requests
import urllib
import arcpy
import os
url = "[query URL]"
#specify the Where clause and output fields
where ="[Field Name IN ('Field Value')]"
fields = "[Out Fields returned from the query]"
#Declare the request part of the web URL into a parameter
params = urllib.parse.urlencode({'where' : where, 'outFields' : fields, 'f' : 'json' })
#Declare the response from the web page
response = requests.get(url+params)
#Retrieve the JSON as a text
jsn = response.text
#Set the environment workspace
arcpy.env.workspace = "C:\\temp
#Save the JSON to a file
file = open("C:\\temp\\myFeatures.json", "a")
file.write(jsn)
file.close()
#Convert the JSON file named myFeatures" and join the storage folder of the current database with the desired database
arcpy.JSONToFeatures_conversion("C:\\temp\\myFeatures.json", os.path.join("C:\\temp\\Data.gdb", "myfeatures"))
                Article ID: 000018476
Get help from ArcGIS experts
Start chatting now