Select to view content in your preferred language

Delete features from featureservice

06-22-2015 08:21 AM
New Contributor


I have collected > 100k features in a hosted feature service (Service definition with 1000 records) and like to delete the features from time to time.

Doing manually, ArcMap allows downloading only 1000 features by time (Service definition with 1000 records), REST (with the WHERE-query 1=1) doesn't work. I get a weird, cryptical answer form the server.

Has anybody experience and a solution?



Tags (2)
0 Kudos
6 Replies
Esri Esteemed Contributor

Hi Christian,

You can use the deleteFeatures with your REST URL.  Ex:

If you want to download the feature class, perform the delete, and then overwrite the hosted feature service take a look at the following tool:

Occasional Contributor

Hi Jake

Thank for your quick reply.

In my case deleteFeatures with your REST URL works for around 2'000 features... but not for 95'000...

Using your script in ArcGIS 10.2.2 results in error message;

Failed script DownloadService...

Traceback (most recent call last):

  File "C:\Users\csailer\Downloads\Export_Feature_Service\Download Service with", line 92, in <module>


  File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\arcobjects\", line 173, in load

    return convertArcObjectToPythonObject(self._arc_object.Load(*gp_fixargs(args)))

RuntimeError: RecordSetObject: Cannot open table for Load

Failed to execute (DownloadService).

However, you have mentioned overwriting the hosted fs with your script?

Thank you!


0 Kudos
Occasional Contributor

Hi Jake

again me. I tried to do some workaroudn. I can delete stepwise features (each time 1000) of my 95'000 fs. services. THE question is why I cannot delete more than ~2000 features from hosted fs per request?

Is ArcGIS Online limiting this request due to server traffic? Why I'm not able to leave a sql statement like;

DELETE FROM table_name;


DELETE * FROM table_name;



0 Kudos
Esri Esteemed Contributor

I'm not sure the max amount of features you can delete at once for an ArcGIS Online Hosted Feature Service.  One thing you could do is use a pythons script to delete features 1000 at a time.  Ex:

import urllib, urllib2, json, smtplib

username = "user"
password = "password"

tokenURL = ''
params = {'f': 'pjson', 'username': username, 'password': password, 'referer': ''}
req = urllib2.Request(tokenURL, urllib.urlencode(params))
response = urllib2.urlopen(req)
data = json.load(response)
token = data['token']

x = 1000

while x <= 95000:
    url = ''
    where = "OBJECTID <= " + str(x)
    params = {'f': 'pjson', 'where': where, 'token': token}
    req = urllib2.Request(url, urllib.urlencode(params))
    response = urllib2.urlopen(req)
    x += 1000
Occasional Contributor

Hi Jake

Thank you this workaround works!


0 Kudos
New Contributor III

I successfully deleted over 100,000 records from a hosted feature layer using the REST Delete Features tool by way of putting 1=1 in the where clause (and nothing in the Object ID field), BUT I did this in my organization's Portal 10.7.1 environment; so, ArcGIS Online might limit how many can be deleted due to cloud resource usage...

*I'm also posting to thank Chris for the 1=1 in where syntax help!

0 Kudos