When trying to delete an orphaned item in portal I get the following message.
Unable to reach the server where the service is. Consider using calling deleteItem with options = { 'force' : true } if the server won't be available anymore.
Where or how do I use the options = {'force' : true}
I cannot find this in any documentation.
Solved! Go to Solution.
Jeff,
You need to access the item using the ArcGIS REST API. Here's a link to the Esri documentation: https://developers.arcgis.com/rest/users-groups-and-items/quick-reference.htm
You can reach the delete item endpoint using this URL pattern:
https://<Portal URL>/sharing/rest/content/users/<username>/items/<itemid>/delete
That endpoint will present you with a UI to delete the item including a checkbox for "Force deletion".
The item id can be found in the URL string within portal, or by navigating to the username REST endpoint:
https://<Portal URL>/sharing/rest/content/users/<username>/
Hope this helps,
Joseph Poncy
Jeff,
You need to access the item using the ArcGIS REST API. Here's a link to the Esri documentation: https://developers.arcgis.com/rest/users-groups-and-items/quick-reference.htm
You can reach the delete item endpoint using this URL pattern:
https://<Portal URL>/sharing/rest/content/users/<username>/items/<itemid>/delete
That endpoint will present you with a UI to delete the item including a checkbox for "Force deletion".
The item id can be found in the URL string within portal, or by navigating to the username REST endpoint:
https://<Portal URL>/sharing/rest/content/users/<username>/
Hope this helps,
Joseph Poncy
Thank you
It is really helpful.
Hi Joseph Poncy and Jeff Timm, apart from this solution, is there a way to delete items from Portal for Arcgis without having to go to Sharing? Any recommendation, idea or suggestion to find the error and to provide a more direct solution? I have the same error. Thanks for all!
Juan,
I am sorry, but I don't fully understand your question. I believe the most direct solution to this problem is through the ArcGIS REST API.
The 'sharing' you see in the solution above is part of the REST endpoint URL.
For example, this is your Portal Root:
More information and examples can be found in the Esri documentation:
Resource hierarchy—ArcGIS REST API: Users, groups, and content | ArcGIS for Developers
(https://developers.arcgis.com/rest/users-groups-and-items/resource-hierarchy.htm)
Root—ArcGIS REST API: Users, groups, and content | ArcGIS for Developers
(https://developers.arcgis.com/rest/users-groups-and-items/root.htm)
Delete Item—ArcGIS REST API: Users, groups, and content | ArcGIS for Developers
(https://developers.arcgis.com/rest/users-groups-and-items/delete-item.htm)
Joseph Poncy
I had to replace "sharing" with "portal" and I was able to delete all my orphaned items.
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]
print(len(filtered_items))
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
Thanks for sharing this solution!
How do I authenticate against ArcGIS Online using https://www.arcgis.com/sharing/rest ?
I just get the below and think it's because I'm not authenticating against AGOL despite being logged in..