<?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 Append Hosted Layer to Feature Class in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/append-hosted-layer-to-feature-class/m-p/1281813#M8627</link>
    <description>&lt;P&gt;Hello all. I'm attempting a script to append records from an ArcGIS Online feature layer to a local geodatabase feature class.&amp;nbsp; I want to run the script nightly as a scheduled task. The below works well when I have Pro open and am logged into ArcGIS Online as my Portal. It fails when I run it as a stand alone script, saying the hosted feature layer does not exist or is not supported. Any advice how to accomplish the append properly? Thanks very much in advance.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;import arcpy
from arcgis import GIS

#connect to ArcGIS Online
agol = GIS(username="username",password="password")

#find the hosted feature layer
item = agol.content.get("6ceffb124830415a9149e7c965e0fd12")
lyr = item.layers[0].url

#reference the geodatbase feature class
fc = r"C:\temp\gdb.sde\GISDB.GIS.TARGET_FC"

#empty the feature class
arcpy.management.TruncateTable(fc)

#append from the feature layer to the feature class
arcpy.Append_management(lyr, fc, "NO_TEST")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 24 Apr 2023 13:31:29 GMT</pubDate>
    <dc:creator>MattFancher1</dc:creator>
    <dc:date>2023-04-24T13:31:29Z</dc:date>
    <item>
      <title>Append Hosted Layer to Feature Class</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/append-hosted-layer-to-feature-class/m-p/1281813#M8627</link>
      <description>&lt;P&gt;Hello all. I'm attempting a script to append records from an ArcGIS Online feature layer to a local geodatabase feature class.&amp;nbsp; I want to run the script nightly as a scheduled task. The below works well when I have Pro open and am logged into ArcGIS Online as my Portal. It fails when I run it as a stand alone script, saying the hosted feature layer does not exist or is not supported. Any advice how to accomplish the append properly? Thanks very much in advance.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;import arcpy
from arcgis import GIS

#connect to ArcGIS Online
agol = GIS(username="username",password="password")

#find the hosted feature layer
item = agol.content.get("6ceffb124830415a9149e7c965e0fd12")
lyr = item.layers[0].url

#reference the geodatbase feature class
fc = r"C:\temp\gdb.sde\GISDB.GIS.TARGET_FC"

#empty the feature class
arcpy.management.TruncateTable(fc)

#append from the feature layer to the feature class
arcpy.Append_management(lyr, fc, "NO_TEST")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 13:31:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/append-hosted-layer-to-feature-class/m-p/1281813#M8627</guid>
      <dc:creator>MattFancher1</dc:creator>
      <dc:date>2023-04-24T13:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: Append Hosted Layer to Feature Class</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/append-hosted-layer-to-feature-class/m-p/1281945#M8628</link>
      <description>&lt;P&gt;You are not establishing the connection to your AGOL portal (when logged in in Pro, that is automagic).&lt;/P&gt;&lt;P&gt;Maybe something like (you supply username and password, but need to identify portal URL):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;#connect to ArcGIS Online
agol = GIS(url='https://yourorg.maps.arcgis.com/',username="username",password="password")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 17:29:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/append-hosted-layer-to-feature-class/m-p/1281945#M8628</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2023-04-24T17:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: Append Hosted Layer to Feature Class</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/append-hosted-layer-to-feature-class/m-p/1281959#M8629</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/15530"&gt;@RhettZufelt&lt;/a&gt;&amp;nbsp; for the response! I tried your suggestion, but unfortunately got the same result saying the feature layer does not exist or is not supported. Any other ideas?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 17:43:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/append-hosted-layer-to-feature-class/m-p/1281959#M8629</guid>
      <dc:creator>MattFancher1</dc:creator>
      <dc:date>2023-04-24T17:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Append Hosted Layer to Feature Class</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/append-hosted-layer-to-feature-class/m-p/1282020#M8630</link>
      <description>&lt;P&gt;Suspect maybe the way you are "getting" the feature layer isn't supported for the append tool.&lt;/P&gt;&lt;P&gt;When I append from HFS to local FGDB, I just use something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;import arcpy
from arcgis.gis import GIS

arcpy.env.preserveGlobalIds = True

fc = r"C:\temp\gdb.sde\GISDB.GIS.TARGET_FC"


gis = GIS(url='https://yourorghere.maps.arcgis.com/', username='AdminUser', password='UsersPass')


in_lyr = 'https://services3.arcgis.com/5asfasga45zb/arcgis/rest/services/GMTest/FeatureServer/1'

#arcpy.management.TruncateTable(fc)

arcpy.Append_management(in_lyr, fc, "NO_TEST")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2023 15:03:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/append-hosted-layer-to-feature-class/m-p/1282020#M8630</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2023-05-01T15:03:37Z</dc:date>
    </item>
  </channel>
</rss>

