Force Delete an Item in Portal for ArcGIS

17231
35
03-07-2016 09:35 AM
Jay_Gregory
Occasional Contributor III

I'm having problems deleting an item in Portal for ArcGIS.  It is delete protected so I can't delete using the UI.  I am unable to change the delete protection because the edit button is also disabled.  I used ArcGIS Online Assistant and tried to change the delete protection from there but the change from true to false wouldn't actually take.  It just kept reverting back.  I tried to find the xml or json file in the item ID folder on the Portal server itself, but I couldn't find the delete protection attribute.  I'm hesitant to just outright delete the item ID folder itself because I don't know if the item ID is registered anywhere else (a user's item list for instance).  Could anyone instruct me on a thorough way to force delete an item from Portal for ArcGIS?

35 Replies
Jay_Gregory
Occasional Contributor III

I have also had a problem deleting an item from Portal after upgrading (in this case, 10.4.1 -> 10.6.1).  When I hit the delete button, a toast pops up that just gives a general error.  I found out that if I make any edit to the Portal item, such as changing the name of item, or tags, etc., and then save the change, I can then delete the item.  

ZacharyHart
Regular Contributor

Interesting behavior...hmm...

My problem is that these items don't exist in the Portal site...they only appear on the 'back-end' when navigating through the portal content interface. In there, deleting the items simply doesn't work.

0 Kudos
JonathanQuinn
Esri Frequent Contributor

If you have orphaned items, deleting files on disk outside of going through the Sharing API won't remove them from the index, which is why they continue to be returned via searches and within the Portal site. Deleting an item through the Sharing API will remove the item from the index.

You could try to reindex after deleting them, but you run a chance of a discrepancy between the database counts and the index counts.

0 Kudos

I just had a problem "arcgis portal failed to determine if item can be deleted" where the problem was related to a bad manual copy/paste error in the Data Source URL, making it invalid.  While the Map Image Layer data source URL was invalid, Portal could not figure out if the item was able to be deleted, so it could not delete the item from Portal.  This is a 10.6.1 portal/server federated environment.

To delete the item from portal which I knew to be invalid rather than doing these steps  https://support.esri.com/en/technical-article/000016345

I deleted the invalid URL leaving the data source URL blank, then I was able to delete the item from portal.

ImtiazSyed
New Contributor III

import arcgis
from arcgis.gis import GIS
gis = GIS("https://portalname/arcgis", "username", "password")

#get the list of orphaned items
delete_orphaned_items = gis.content.search(query="owner: ownername AND title:*title*",item_type='Feature *', max_items=100)
delete_orphaned_items

#filter the items 
filtered_items = [item for item in delete_orphaned_items if 'title' in item.title]
sorted(filtered_items, key=lambda x:x.title)

#replace dry_run with force. dry_run checks if the item can be safely deleted
for item in filtered_items:
try:
item.delete(dry_run=True)
except TypeError:
print(f'{item.title} not deleted')
except RuntimeError:
print(f'{item.title} not deleted')

 

Delete an item in Portal for ArcGIS using arcgis.gis module: https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html#item

 

https://community.esri.com/people/syed_imtiaz/blog/2019/07/15/delete-orphaned-items-from-portal-for-...

0 Kudos
RhysDonoghue2
New Contributor III

If this helps anyone, you can delete an item via this URL:

https://[your server]/[your portal name]/sharing/rest/content/users/[your username] - This will show you the content you own, then you can click on the item, then delete it.  I had to do this for content that was not showing up in Portal for ArcGIS.  I knew it was there and went looking for it and found it via the URL above.

Imtiaz Syed‌ - Nice script, thanks for sharing.

0 Kudos