<?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: gis.content.search() exclude Deprecated items? in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/gis-content-search-exclude-deprecated-items/m-p/1360197#M9408</link>
    <description>&lt;P&gt;the content_status will show this&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html" target="_blank"&gt;https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;try something like&lt;/P&gt;&lt;P&gt;from arcgis.gis import GIS&lt;BR /&gt;from arcgis.mapping import WebMap&lt;BR /&gt;import arcpy&lt;/P&gt;&lt;P&gt;gis = GIS("pro")&lt;/P&gt;&lt;P&gt;service_contents = gis.content.search("*", item_type="Web Map", max_items=1000)&lt;/P&gt;&lt;P&gt;print('Number of Web Maps found: ' + str(len(service_contents)))&lt;/P&gt;&lt;P&gt;# print the service title if the content_status is not deprecated&lt;BR /&gt;for service in service_contents:&lt;BR /&gt;item = gis.content.get(service.id)&lt;BR /&gt;if item.content_status != "deprecated":&lt;BR /&gt;print(service.title)&lt;/P&gt;&lt;P&gt;print("Finished")&lt;/P&gt;</description>
    <pubDate>Wed, 13 Dec 2023 10:27:49 GMT</pubDate>
    <dc:creator>ChristopherCounsell</dc:creator>
    <dc:date>2023-12-13T10:27:49Z</dc:date>
    <item>
      <title>gis.content.search() exclude Deprecated items?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/gis-content-search-exclude-deprecated-items/m-p/1360154#M9407</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I've written code below to print a list of Web Maps in my Enterprise Portal.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to exclude Deprecated Web Maps from the search results.&amp;nbsp; Can I add a parameter to do this?&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;from arcgis.gis import GIS&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;from arcgis.mapping import WebMap&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;import arcpy&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;gis = GIS("pro")&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;service_contents = gis.content.search("*",item_type="Web Map", max_items = 1000)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;print('Number of Web Maps found: ' + str((len(service_contents))))&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;#print the service title&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;for service in service_contents:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;print(service.title)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;print("Finished")&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 06:19:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/gis-content-search-exclude-deprecated-items/m-p/1360154#M9407</guid>
      <dc:creator>Kalu_Ribush</dc:creator>
      <dc:date>2023-12-13T06:19:40Z</dc:date>
    </item>
    <item>
      <title>Re: gis.content.search() exclude Deprecated items?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/gis-content-search-exclude-deprecated-items/m-p/1360197#M9408</link>
      <description>&lt;P&gt;the content_status will show this&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html" target="_blank"&gt;https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;try something like&lt;/P&gt;&lt;P&gt;from arcgis.gis import GIS&lt;BR /&gt;from arcgis.mapping import WebMap&lt;BR /&gt;import arcpy&lt;/P&gt;&lt;P&gt;gis = GIS("pro")&lt;/P&gt;&lt;P&gt;service_contents = gis.content.search("*", item_type="Web Map", max_items=1000)&lt;/P&gt;&lt;P&gt;print('Number of Web Maps found: ' + str(len(service_contents)))&lt;/P&gt;&lt;P&gt;# print the service title if the content_status is not deprecated&lt;BR /&gt;for service in service_contents:&lt;BR /&gt;item = gis.content.get(service.id)&lt;BR /&gt;if item.content_status != "deprecated":&lt;BR /&gt;print(service.title)&lt;/P&gt;&lt;P&gt;print("Finished")&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 10:27:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/gis-content-search-exclude-deprecated-items/m-p/1360197#M9408</guid>
      <dc:creator>ChristopherCounsell</dc:creator>
      <dc:date>2023-12-13T10:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: gis.content.search() exclude Deprecated items?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/gis-content-search-exclude-deprecated-items/m-p/1360662#M9414</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/412943"&gt;@ChristopherCounsell&lt;/a&gt;&amp;nbsp;.&amp;nbsp; Thanks for response&lt;/P&gt;&lt;P&gt;Unfortunately I get this error message:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Kalu_Ribush_0-1702505257507.png" style="width: 758px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/88987i97A408AFEBF9EDAF/image-dimensions/758x157?v=v2" width="758" height="157" role="button" title="Kalu_Ribush_0-1702505257507.png" alt="Kalu_Ribush_0-1702505257507.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Any advice apprreciated.&amp;nbsp; Can I get it to ignore the error or skip that record?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 22:08:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/gis-content-search-exclude-deprecated-items/m-p/1360662#M9414</guid>
      <dc:creator>Kalu_Ribush</dc:creator>
      <dc:date>2023-12-13T22:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: gis.content.search() exclude Deprecated items?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/gis-content-search-exclude-deprecated-items/m-p/1360673#M9415</link>
      <description>&lt;P&gt;Sorry I didn't test the script, but the content_status property is what you are looking for. It's likely not there for those without the property so you need to update script to handle it.&lt;/P&gt;&lt;P&gt;Try this one. It'll loop through and return the content_status. It can be empty, org_authoritative, deprecated, etc&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS

# Connect to your GIS using a specific profile or URL
gis = GIS("Home")

# Get the username of the logged-in user
user = gis.users.me.username

# Construct a query to search for web maps owned by the user
owner_query = "owner:" + user

# Search for web maps based on the query. Set max_items to -1 for all maps
webmaps = gis.content.search(query=owner_query, item_type="Web Map", max_items=10)

# Print the content status of each web map
for webmap in webmaps:
print(webmap.content_status)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;You'll need to add logic to your script to handle the property. e.g. here's one for authoritative content&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-use-the-content-status-property/m-p/1052915" target="_blank"&gt;https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-use-the-content-status-property/m-p/1052915&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 22:47:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/gis-content-search-exclude-deprecated-items/m-p/1360673#M9415</guid>
      <dc:creator>ChristopherCounsell</dc:creator>
      <dc:date>2023-12-13T22:47:11Z</dc:date>
    </item>
  </channel>
</rss>

