I do not believe this is a copy of Download Dataset From ArcGIS REST Service or Extracting data from ArcGIS REST endpoint? due to the source and type of service.

I would like to copy the features from a government ArcGIS REST Service. It is a MapServer so I am not sure how, or if it is possible. I tried replicating a code I used to copy a FeatureServer but that did not work and instead got an ERROR 999999 which isn't very helpful for diagnosing what is wrong.

The code is as follows:

# Set environment options

# Set workspace 
ws = r'c:/ws'
wsGDB = os.path.join(ws, 'EnvironmentalContamination.gdb')

# MO Hazardous Waste from DNR
conFields = "https://gis.dnr.mo.gov/arcgis/rest/services/e_start/e_start/MapServer/0"
# Copy fc from rest service
conCopy = "MOContamination"
memCon = arcpy.management.CopyFeatures(conFields, conCopy)
  • you need to look at the formats that are available to download - you can check the wizard gis.dnr.mo.gov/arcgis/rest/services/e_start/e_start/MapServer/…
    – Mapperz
    Commented May 27, 2021 at 13:18
  • 1
    This works, inside ArcGIS Pro. I added the layer to the map (via URL), then used the layer reference in CopyFeatures. The issue is probably using a MapService with CopyFeatures; it probably only supports a FeatureService
    – KHibma
    Commented May 27, 2021 at 14:42

1 Answer 1


I believe CopyFeatures can only work directly on a FeatureService. You can make use of arcpy.FeatureSet to put a wrapper on the MapService, which CopyFeatures supports.

fs = arcpy.FeatureSet()
arcpy.management.CopyFeatures(fs, "Foo2")

However, this service seems pretty slow. If you run CopyFeatures too soon after doing the load, CopyFeatures will still fail as the data hasn't been brought down.

  • Would adding some kind of python code to tell it to 'stall' or wait after loading make sense then? Commented May 28, 2021 at 12:49
  • Hm..even with a 5 minute sleep delay, I'm only getting a single record using this. Commented May 28, 2021 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.