Select to view content in your preferred language

deleteItem with options = { 'force' : true }

7757
9
Jump to solution
10-04-2018 11:57 AM
JeffTimm
Frequent Contributor

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.

1 Solution

Accepted Solutions
JosephPoncy
Occasional Contributor

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

Geospatial Developer
Innovate! Inc.

Innovate!, Inc. is a Virginia-based 8(a), Hispanic- and woman-owned business delivering Geospatial, Information Technology, Security, Business Consulting, Project Management and Executive Coaching solutions to our government and private sector clients.  Check us out at www.innovateteam.com.

View solution in original post

9 Replies
JosephPoncy
Occasional Contributor

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

Geospatial Developer
Innovate! Inc.

Innovate!, Inc. is a Virginia-based 8(a), Hispanic- and woman-owned business delivering Geospatial, Information Technology, Security, Business Consulting, Project Management and Executive Coaching solutions to our government and private sector clients.  Check us out at www.innovateteam.com.
JeffTimm
Frequent Contributor

Thank you

0 Kudos
chakreshsahu
Occasional Contributor

It is really helpful.

0 Kudos
IngJuanMaSuarez
Esri Contributor

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!

0 Kudos
JosephPoncy
Occasional Contributor

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

Geospatial Developer
Innovate! Inc.
 
Innovate!, Inc. is a Virginia-based 8(a), Hispanic- and woman-owned business delivering Geospatial, Information Technology, Security, Business Consulting, Project Management and Executive Coaching solutions to our government and private sector clients.  Check us out at www.innovateteam.com
0 Kudos
LukeCatania
Occasional Contributor

I had to replace "sharing" with "portal" and I was able to delete all my orphaned items.

0 Kudos
ImtiazSyed
Occasional Contributor
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

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

JosephPoncy
Occasional Contributor

Thanks for sharing this solution!

0 Kudos
ahargreaves_FW
Frequent Contributor

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..

ahargreaves_FW_0-1709082585614.png

 

 

 

0 Kudos