ERROR

Cannot open table for Load

Last Published: April 25, 2020

Error Message

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
User-added image

Cause

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.

Solution or Workaround

Use one of the following options to resolve the issue:
  • Create a Python script based on the features queried at the REST endpoint of the map service. Save the response as a JSON file, and use ArcPy to convert the JSON file to a feature layer that is saved in a local geodatabase. The Python script is used to access the map service.
    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).
    1. Query the desired features with the attribute table data at the REST endpoint of the map service in a JSON format.
      1. Specify the Where clause with the desired features.
      2. Optionally, specify the Out Fields parameter to limit the fields in the resulting JSON file.
    2. Create a Python script to insert all the features with the attribute table data from the query to return in the JSON format.
#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

Software:
  • ArcMap
  • ArcGIS Server

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options