<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Python API: Delete using &amp;quot;title&amp;quot; instead of &amp;quot;itemid&amp;quot; ?? in ArcGIS Enterprise Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-questions/python-api-delete-using-quot-title-quot-instead-of/m-p/1062466#M30323</link>
    <description>&lt;P&gt;That would mean your search is returning no items? But you say that finding it by itself works, so that would be strange. It may be simpler to take the server approach instead.&lt;/P&gt;</description>
    <pubDate>Thu, 27 May 2021 17:47:35 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2021-05-27T17:47:35Z</dc:date>
    <item>
      <title>Python API: Delete using "title" instead of "itemid" ??</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/python-api-delete-using-quot-title-quot-instead-of/m-p/1062380#M30318</link>
      <description>&lt;P&gt;Is there a way to delete a Geoportal service using ArcGIS Python API without using the item id? I need to delete a geocode service and publish it with the exact same name, weekly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I use the "itemid" than I can't make this an automated task, because each time you publish a service the "itemid" changes.. I know I can search for an item, but you can't delete an item from "gis.content.search".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using gis.content.get()&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 15:50:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/python-api-delete-using-quot-title-quot-instead-of/m-p/1062380#M30318</guid>
      <dc:creator>TimothyCallahan</dc:creator>
      <dc:date>2021-05-27T15:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Python API: Delete using "title" instead of "itemid" ??</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/python-api-delete-using-quot-title-quot-instead-of/m-p/1062421#M30320</link>
      <description>&lt;P&gt;Could you search for the item title and type, extract the ID, then pass that into the delete method?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis import GIS


gis = GIS("https://portal.domain.com","administrator","administratorpassword",verify_cert=False)
itemID = gis.content.search("SampleWorldCities","Map Service")[0].id
item = gis.content.get(itemID)
item.delete()&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 27 May 2021 16:53:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/python-api-delete-using-quot-title-quot-instead-of/m-p/1062421#M30320</guid>
      <dc:creator>JonathanQuinn</dc:creator>
      <dc:date>2021-05-27T16:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: Python API: Delete using "title" instead of "itemid" ??</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/python-api-delete-using-quot-title-quot-instead-of/m-p/1062434#M30321</link>
      <description>&lt;P&gt;A service's title is not unique, so there's no way for the API to know &lt;EM&gt;which &lt;/EM&gt;item you're intending to delete. As long as you're careful in maintaining a &lt;EM&gt;single&lt;/EM&gt; item with that name, you could do something like the following:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Search for the item by name, return the itemid
item_id = gis.content.search('the specific name of the item', item_type='the item type')[0].id

# Reference the returned ID in the delete function
gis.content.delete_items([item_id])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alternately, if you trust your search to always return the single item you want, you can also do:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;gis.content.search('the specific name of the item', item_type='the item type')[0].delete()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And as a final alternative, you can avoid the itemid altogether by going straight to the Service that you have published.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;server = gis.admin.servers.get('HOSTING_SERVER')[0]

service = server.content.find('service name').service.delete()&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 27 May 2021 17:12:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/python-api-delete-using-quot-title-quot-instead-of/m-p/1062434#M30321</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-05-27T17:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: Python API: Delete using "title" instead of "itemid" ??</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/python-api-delete-using-quot-title-quot-instead-of/m-p/1062464#M30322</link>
      <description>&lt;P&gt;item_id = gis.content.search(query='title:PARCEL_GEOCODE_TEST_2', item_type='Geocoding Layer')&lt;/P&gt;&lt;P&gt;Finding the item works, but I am having issues getting the id to print. If I put [0].id I get an error; IndexError: list index out of range..&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 17:45:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/python-api-delete-using-quot-title-quot-instead-of/m-p/1062464#M30322</guid>
      <dc:creator>TimothyCallahan</dc:creator>
      <dc:date>2021-05-27T17:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: Python API: Delete using "title" instead of "itemid" ??</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/python-api-delete-using-quot-title-quot-instead-of/m-p/1062466#M30323</link>
      <description>&lt;P&gt;That would mean your search is returning no items? But you say that finding it by itself works, so that would be strange. It may be simpler to take the server approach instead.&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 17:47:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/python-api-delete-using-quot-title-quot-instead-of/m-p/1062466#M30323</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-05-27T17:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: Python API: Delete using "title" instead of "itemid" ??</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/python-api-delete-using-quot-title-quot-instead-of/m-p/1062599#M30330</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="No id.PNG" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/14409i47522E984C9B79E8/image-size/large?v=v2&amp;amp;px=999" role="button" title="No id.PNG" alt="No id.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 21:55:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/python-api-delete-using-quot-title-quot-instead-of/m-p/1062599#M30330</guid>
      <dc:creator>TimothyCallahan</dc:creator>
      <dc:date>2021-05-27T21:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: Python API: Delete using "title" instead of "itemid" ??</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/python-api-delete-using-quot-title-quot-instead-of/m-p/1062643#M30331</link>
      <description>&lt;P&gt;In your image, &lt;STRONG&gt;ItemID&lt;/STRONG&gt; is a list of items, as denoted by the brackets. You need to call the list item by using &lt;STRONG&gt;ItemID[0]&lt;/STRONG&gt;, then you can get the ID from it.&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 21:58:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/python-api-delete-using-quot-title-quot-instead-of/m-p/1062643#M30331</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-05-27T21:58:12Z</dc:date>
    </item>
  </channel>
</rss>

