<?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: How to query Feature Layer to get objects that have an attachment? in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-feature-layer-to-get-objects-that/m-p/1138313#M7055</link>
    <description>&lt;P&gt;hello&lt;BR /&gt;this code might help you, it is used in the arcgisonline notebook.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/Survey123-tools/blob/4ad217209681f29c3ad98636e664a532c0ffd85a/Export_survey_data_with_attachments/export_survey_data_with_attachments.ipynb" target="_blank"&gt;https://github.com/Esri/Survey123-tools/blob/4ad217209681f29c3ad98636e664a532c0ffd85a/Export_survey_data_with_attachments/export_survey_data_with_attachments.ipynb&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
    <pubDate>Fri, 28 Jan 2022 13:14:27 GMT</pubDate>
    <dc:creator>JavierCMartínezPrieto</dc:creator>
    <dc:date>2022-01-28T13:14:27Z</dc:date>
    <item>
      <title>How to query Feature Layer to get objects that have an attachment?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-feature-layer-to-get-objects-that/m-p/1138292#M7054</link>
      <description>&lt;P&gt;I want to download attachments from an ArcGIS Online Feature Layer and use them for further operations. So far, I did this using&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;search_result = gis.content.search(ArcGIS_content, "Feature Layer")&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;item = search_result[0]&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;FeatureLayer = item.layers[0]&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;FeatureObjectIDs = FeatureLayer.query(where = "1=1", return_ids_only = True)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;for objID in FeatureObjectIDs["objectIds"]:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print("Checking object", str(objID) + "...")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; attachments_list = FeatureLayer.attachments.get_list(oid = objID)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;in order to get the object IDs and then iterate through all items of the Feature Layer. However, this takes a lot of time and few items actually have an attachment. How can I change the &lt;FONT face="courier new,courier"&gt;where&lt;/FONT&gt; parameter so I get only the object IDs of objects with an attachment?&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jan 2022 12:17:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-feature-layer-to-get-objects-that/m-p/1138292#M7054</guid>
      <dc:creator>Manu</dc:creator>
      <dc:date>2022-01-28T12:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to query Feature Layer to get objects that have an attachment?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-feature-layer-to-get-objects-that/m-p/1138313#M7055</link>
      <description>&lt;P&gt;hello&lt;BR /&gt;this code might help you, it is used in the arcgisonline notebook.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/Survey123-tools/blob/4ad217209681f29c3ad98636e664a532c0ffd85a/Export_survey_data_with_attachments/export_survey_data_with_attachments.ipynb" target="_blank"&gt;https://github.com/Esri/Survey123-tools/blob/4ad217209681f29c3ad98636e664a532c0ffd85a/Export_survey_data_with_attachments/export_survey_data_with_attachments.ipynb&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jan 2022 13:14:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-feature-layer-to-get-objects-that/m-p/1138313#M7055</guid>
      <dc:creator>JavierCMartínezPrieto</dc:creator>
      <dc:date>2022-01-28T13:14:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to query Feature Layer to get objects that have an attachment?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-feature-layer-to-get-objects-that/m-p/1138327#M7056</link>
      <description>&lt;P&gt;The Attachment Manager submodule of the Python API does allow you to do a &lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.features.managers.html#arcgis.features.managers.AttachmentManager.search" target="_self"&gt;query on all attachments&lt;/A&gt;. If you do not specify a query string, it will return information about every attachment from the layer.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1643376625210.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/32575i84D3BAEF3D2C296C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1643376625210.png" alt="jcarlson_0-1643376625210.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notably, the output includes the parent object/global ID. You can pull that column out and turn around to query the parent service with that list.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;l = gis.content.get('647e966722f943d0b5d49f82288a839e').layers[0] # adjust as needed to get your particular service / layer

attachments = l.attachments.search(as_df=True)

attachments['PARENTOBJECTID'].drop_duplicates().to_list()&lt;/LI-CODE&gt;&lt;P&gt;The result: a list of objectids with attachments!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_1-1643377563352.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/32576iA0598273C23B336F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_1-1643377563352.png" alt="jcarlson_1-1643377563352.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Now, that addresses the &lt;EM&gt;title &lt;/EM&gt;of your post. But in the body of your post, you mention downloading the items, too. You could feed that objectid list into your original script if you like, but it's worth noting that using the &lt;STRONG&gt;attachments.search()&lt;/STRONG&gt; method and returning the results as a dict (as opposed to a DataFrame), each attachment includes the property "DOWNLOAD_URL".&lt;/P&gt;&lt;P&gt;So you &lt;EM&gt;could&lt;/EM&gt; try something like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;downloads = [a['DOWNLOAD_URL'] for a in l.attachments.search()]&lt;/LI-CODE&gt;&lt;P&gt;And then you have list of URLs from which you can iteratively download every attachment.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_2-1643378003856.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/32578i19FCE38ABA06FBB9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_2-1643378003856.png" alt="jcarlson_2-1643378003856.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jan 2022 13:53:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-feature-layer-to-get-objects-that/m-p/1138327#M7056</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-01-28T13:53:14Z</dc:date>
    </item>
  </channel>
</rss>

