Hi Everyone,
I work in a one-man GIS team, and one of my main tasks is processing data collected via Field Maps. Once the field workers sync their data collection devices, I process multiple feature classes into a new hosted feature service in AGOL.
Throughout my scripts process it checks if certain feature services exist and if they do to delete them. With the new recycle bin feature my script fails because it is not "permanently deleted" it is just hanging out in the recycle bin. I can manually navigate to the recycle bin and manually delete it and my script works like it normally does.
Has anyone else experienced something like this? I imagine there must be a way to permanently delete an item in AGOL and have it not enter the recycle bin just deleted.
Solved! Go to Solution.
item delete has a "permanent" parameter available (https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#item).
"Optional boolean. Available in ArcGIS Online, setting to True will permanently delete the item rather than sending it to the recycle bin."
This might be what you are looking for?
item delete has a "permanent" parameter available (https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#item).
"Optional boolean. Available in ArcGIS Online, setting to True will permanently delete the item rather than sending it to the recycle bin."
This might be what you are looking for?
Thank you Justin you are a life saver!
Maybe there is a programmatic way to toggle off the AGOL Recycle bin while you are running your scripts?
Has anyone successfully been able to permanently delete an AGOL item via Python AFTER ESRI added the recycle bin?
from arcgis.gis import GIS
gis = GIS("home")
item_id='767ff8fe699047d7bc0e74c0f15a63a4' #this is the service_ID of the hosted feature layer to delete
itemToDelete = gis.content.get(item_id)
itemToDelete.delete(permanent=True)
Running this code in AGOL Notebooks as well as Python 3.9.16 on my computer with Pro 3.1.2 I get the following error message:
TypeError Traceback (most recent call last)
/tmp/ipykernel_19/3146111176.py in <cell line: 7>()
5
6 itemToDelete = gis.content.get(item_id)
----> 7 itemToDelete.delete(permanent=True)
TypeError: delete() got an unexpected keyword argument 'permanent'
I too am seeing: TypeError: delete() got an unexpected keyword argument 'permanent'
I had Python that was deleting items on AGOL and then copying up to AGOL updated like named items. After we turned on the recycle bin the copying up wasn't working anymore since the like named items were in the Recycle Bin. Found this thread but now seeing issues with the 'permanent' option.
I am retrieving the item by name but have also retrieved it by item ID with the same results.
Python 3.9.18 ArcGIS Pro 3.2.0
I was getting the same error trying to use item.delete(permanent=True) in an ArcGIS Notebook @GregHorne, @Tom_Laue. But once I updated my Notebook to use the latest runtime it worked fine and the item is deleted permanently without going anywhere near the recycle bin. The Notebook Runtime setting is on the Setting page of the item in AGOL, I just set it to the most recent version:
Hope this helps.
@Tom_Laue For executing from Python on the desktop, it looks like the issue is that one needs to use arcgis (ArcGIS API for Python) v 2.3.0 which comes with ArcGIS Pro v3.3.0. I tried using Pro v3.1 and v3.2 which comes with arcgis v2.2.0.1.
I am not familiar with cloning Python environments but I did try that with Pro v3.1 and v3.2 and then attempted to update the arcgis package but that did not help. It never upgraded out of v2.2.0.x