<?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: SearchCursor cannot open Hosted feature layer in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/searchcursor-cannot-open-hosted-feature-layer/m-p/1072687#M6269</link>
    <description>&lt;P&gt;I should have posted a sample URL too.&amp;nbsp; Does it end in FeatureServer?&amp;nbsp; Then you give it the number of the layer you want.&amp;nbsp; You may be giving it the /MapServer URL instead.&lt;/P&gt;&lt;P&gt;url&amp;nbsp; = "&lt;A href="https://services1.arcgis.com/Hp6G80Pky0om7QvQ/ArcGIS/rest/services/BLM_Natl_AIM_Lentic_2021_Service/FeatureServer/0&amp;quot;" target="_blank"&gt;https://services1.arcgis.com/Hp6G80Pky0om7QvQ/ArcGIS/rest/services/MyServiceName/FeatureServer/0"&lt;/A&gt;&lt;/P&gt;&lt;P&gt;soilpitF = arcpy.RecordSet()&lt;BR /&gt;soilpitF.load(url)&lt;/P&gt;&lt;P&gt;Sorry I should have posted the complete code.&amp;nbsp; Seems like you are trying to look it up instead?&amp;nbsp; I would just give it the URL to the service.&lt;/P&gt;&lt;P&gt;You get this from the Item page of the service&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DougBrowning_0-1624640981295.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/17020iA8CAE002511F5128/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DougBrowning_0-1624640981295.png" alt="DougBrowning_0-1624640981295.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Hope that works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 25 Jun 2021 17:10:47 GMT</pubDate>
    <dc:creator>DougBrowning</dc:creator>
    <dc:date>2021-06-25T17:10:47Z</dc:date>
    <item>
      <title>SearchCursor cannot open Hosted feature layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/searchcursor-cannot-open-hosted-feature-layer/m-p/1072310#M6263</link>
      <description>&lt;P&gt;I am trying to use arcpy cursors on a hosted feature layer containing a geodatabase with multiple tables and feature classes. After digging around the internet, a few posts seem to allude that I can do this:&lt;/P&gt;&lt;P&gt;&lt;A href="https://gis.stackexchange.com/questions/363932/how-can-i-use-updatecursor-in-agol-layers" target="_blank" rel="noopener"&gt;https://gis.stackexchange.com/questions/363932/how-can-i-use-updatecursor-in-agol-layers&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-api-for-python-questions/updatecursor-with-a-hosted-table/td-p/781002" target="_blank" rel="noopener"&gt;https://community.esri.com/t5/arcgis-api-for-python-questions/updatecursor-with-a-hosted-table/td-p/781002&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Whereby, it seems the process is to:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Access ArcGIS Online account&lt;/LI&gt;&lt;LI&gt;Search for the hosted feature layer in my content&lt;/LI&gt;&lt;LI&gt;Use the URL for the item as the first parameter in the arcpy cursor (i.e. arcpy.da.SearchCursor(item.url, fields))&lt;/LI&gt;&lt;LI&gt;Run Cursor&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;So, code looks something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
import arcpy

gis = GIS("https://www.arcgis.com", "username", "password")

hfl = gis.content.get('itemitd')

url = hfl.tables[8]

with arcpy.da.SearchCursor(url, '*') as cursor:
    for row in cursor:
        print(row)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Which returns the following error:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;RuntimeError: cannot open '&lt;A href="https://services6.arcgis.com/yadda/arcgis/rest/services/nameofhostedfeaturelayer/FeatureServer/10" target="_blank" rel="noopener"&gt;https://services6.arcgis.com/yadda/arcgis/rest/services/nameofhostedfeaturelayer/FeatureServer/10&lt;/A&gt;'&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I tried using a slightly different approach to grab the item, but is pretty much the same as the above:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;hfl = gis.content.search(query="title:nameofhostedfeaturelayer, owner:username", max_items=1000)

url = hfl[0].tables[8].url

with arcpy.da.UpdateCursor(url , "*") as cursor:
    for row in cursor:
        row[0] = "hello"
        cursor.updateRow(row) &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Which yields the same error.&lt;/P&gt;&lt;P&gt;Couple notes:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I own the data&lt;/LI&gt;&lt;LI&gt;It is shared to a few groups, but not publicly&lt;/LI&gt;&lt;LI&gt;I've allowed edits on the hosted feature layer and any other setting that may or may not allow the script to see and read the hosted feature layer&lt;/LI&gt;&lt;LI&gt;It appears I do have access to the hosted feature layer and I can perform other operations on it such as printing out items or values:&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for v in hfl.values():
    print(o)

for i in hfl.items():
    print(c)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions why I am receiving that error?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 21:04:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/searchcursor-cannot-open-hosted-feature-layer/m-p/1072310#M6263</guid>
      <dc:creator>MikeMacRae</dc:creator>
      <dc:date>2021-06-24T21:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: SearchCursor cannot open Hosted feature layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/searchcursor-cannot-open-hosted-feature-layer/m-p/1072329#M6264</link>
      <description>&lt;P&gt;What I do is load the HFS in once to a FeatureSet then I can use it many times without more calls.&amp;nbsp; I know not your question but it may help you.&lt;/P&gt;&lt;P&gt;specrichF = arcpy.FeatureSet()&lt;BR /&gt;specrichF.load(specrichURL)&lt;/P&gt;&lt;P&gt;with arcpy.da.SearchCursor(specrichF,......&lt;/P&gt;&lt;P&gt;Hope that helps&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 21:16:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/searchcursor-cannot-open-hosted-feature-layer/m-p/1072329#M6264</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2021-06-24T21:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: SearchCursor cannot open Hosted feature layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/searchcursor-cannot-open-hosted-feature-layer/m-p/1072338#M6265</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/16421"&gt;@DougBrowning&lt;/a&gt; I tested your suggestion (think that was a similar approach in one of the other links I posted above) and it returns the following error:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;HR /&gt;RuntimeError: RecordSetObject: Cannot open table for Load&lt;/BLOCKQUOTE&gt;&lt;P&gt;So, there's something that is preventing the cursor from opening/accessing the table...&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 21:25:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/searchcursor-cannot-open-hosted-feature-layer/m-p/1072338#M6265</guid>
      <dc:creator>MikeMacRae</dc:creator>
      <dc:date>2021-06-24T21:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: SearchCursor cannot open Hosted feature layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/searchcursor-cannot-open-hosted-feature-layer/m-p/1072412#M6266</link>
      <description>&lt;P&gt;I knew I should posted that if it is a table you need to use RecordSet&lt;/P&gt;&lt;P&gt;soilpitF = arcpy.RecordSet()&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jun 2021 00:20:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/searchcursor-cannot-open-hosted-feature-layer/m-p/1072412#M6266</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2021-06-25T00:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: SearchCursor cannot open Hosted feature layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/searchcursor-cannot-open-hosted-feature-layer/m-p/1072666#M6268</link>
      <description>&lt;P&gt;Thanks again &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/16421"&gt;@DougBrowning&lt;/a&gt; I think the coding you are providing is correct and you are right. I am trying this on a table but I also tested on a layer as well and it just doesn't seem to be accessing either of them with the cursor.&lt;/P&gt;&lt;P&gt;I did come across an &lt;A href="https://support.esri.com/en/technical-article/000018476" target="_blank" rel="noopener"&gt;ESRI support document&lt;/A&gt; that speaks to the errors I am receiving and how a map service can't access the attribute table, but according to the metadata on my hosted feature service, it is a feature layer, not a map service:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MikeMacRae_1-1624639204340.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/17017i402A09348A104771/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MikeMacRae_1-1624639204340.png" alt="MikeMacRae_1-1624639204340.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jun 2021 16:40:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/searchcursor-cannot-open-hosted-feature-layer/m-p/1072666#M6268</guid>
      <dc:creator>MikeMacRae</dc:creator>
      <dc:date>2021-06-25T16:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: SearchCursor cannot open Hosted feature layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/searchcursor-cannot-open-hosted-feature-layer/m-p/1072687#M6269</link>
      <description>&lt;P&gt;I should have posted a sample URL too.&amp;nbsp; Does it end in FeatureServer?&amp;nbsp; Then you give it the number of the layer you want.&amp;nbsp; You may be giving it the /MapServer URL instead.&lt;/P&gt;&lt;P&gt;url&amp;nbsp; = "&lt;A href="https://services1.arcgis.com/Hp6G80Pky0om7QvQ/ArcGIS/rest/services/BLM_Natl_AIM_Lentic_2021_Service/FeatureServer/0&amp;quot;" target="_blank"&gt;https://services1.arcgis.com/Hp6G80Pky0om7QvQ/ArcGIS/rest/services/MyServiceName/FeatureServer/0"&lt;/A&gt;&lt;/P&gt;&lt;P&gt;soilpitF = arcpy.RecordSet()&lt;BR /&gt;soilpitF.load(url)&lt;/P&gt;&lt;P&gt;Sorry I should have posted the complete code.&amp;nbsp; Seems like you are trying to look it up instead?&amp;nbsp; I would just give it the URL to the service.&lt;/P&gt;&lt;P&gt;You get this from the Item page of the service&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DougBrowning_0-1624640981295.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/17020iA8CAE002511F5128/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DougBrowning_0-1624640981295.png" alt="DougBrowning_0-1624640981295.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Hope that works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jun 2021 17:10:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/searchcursor-cannot-open-hosted-feature-layer/m-p/1072687#M6269</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2021-06-25T17:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: SearchCursor cannot open Hosted feature layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/searchcursor-cannot-open-hosted-feature-layer/m-p/1392499#M9726</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;What finally made it work for me was to add the portal connection in ArcGIS Pro.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2024 13:40:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/searchcursor-cannot-open-hosted-feature-layer/m-p/1392499#M9726</guid>
      <dc:creator>HenrikSchmidt</dc:creator>
      <dc:date>2024-03-07T13:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: SearchCursor cannot open Hosted feature layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/searchcursor-cannot-open-hosted-feature-layer/m-p/1392551#M9727</link>
      <description>&lt;P&gt;Based on a notification updating this post.&lt;/P&gt;&lt;P&gt;In the end I found out that using RecordSet or FeatureSet actually just makes a pointer to the online data and does not load anything into a Python var or memory like I thought.&amp;nbsp; Found out once the service grew in size my script starting taking 30-60 mins to run!&lt;/P&gt;&lt;P&gt;So I totally gave up on using it and instead specifically copy everything into memory like this&lt;/P&gt;&lt;P&gt;arcpy.conversion.FeatureClassToFeatureClass(plotsURL, "memory", "plots")&lt;BR /&gt;plotsF = "memory\\plots"&lt;/P&gt;&lt;P&gt;The script now runs in 1-3 minutes!&amp;nbsp; Way better way to do it.&amp;nbsp; &amp;nbsp;Also note the new memory in Pro vs the older in_memory is also much faster.&amp;nbsp; Changing this cut the script run time in half again.&amp;nbsp; I have since converted all my scripts to copying to memory right away at the top of the script and it is working really well and crazy fast.&lt;/P&gt;&lt;P&gt;Also note I do the second line&amp;nbsp;plotsF = "memory\\plots" just so that I can use var type ahead in PyScripter.&amp;nbsp; You could write out&amp;nbsp;"memory\\plots" each time but a var is way easier.&amp;nbsp; Also note GP tools may not like the \\ part so you can instead use&amp;nbsp;plotsF = os.path.join(memory,plots) and I am pretty sure that was working fine but I forget.&lt;/P&gt;&lt;P&gt;Sorry for the late update but hope it helps someone.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2024 14:40:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/searchcursor-cannot-open-hosted-feature-layer/m-p/1392551#M9727</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2024-03-07T14:40:58Z</dc:date>
    </item>
  </channel>
</rss>

