<?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: item.copy_feature_layer_collection  fails in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/item-copy-feature-layer-collection-fails/m-p/1648066#M11617</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/131962"&gt;@JoeNunn&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I use the same workflow but I haven't had any issues. Here's my code below. Also works fine in an ArcGIS Online Notebook.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS

################################################################################
## USER INPUT ##################################################################

new_service_name = "TESTING_DEEP_COPY"

item_id = "FS_ITEM_ID"

################################################################################
## ACCESS ARCGIS ONLINE ########################################################

agol = GIS("home")

################################################################################
## GET THE FEATURE SERVICE ITEM OBJECT #########################################

item = agol.content.get(item_id)

################################################################################
## INTEGER LISTS OF LAYERS &amp;amp; TABLES ############################################

## get the layer indexes
layers = list(range(len(item.layers)))

## get the table indexes
tables = list(range(len(item.tables)))

################################################################################
## COPY THE FEATURE SERVICE OBJECT ITEM ########################################

## copy the item - copies the shell/schema, no data is added to the layers/tables
copied_item = item.copy_feature_layer_collection(
    service_name = new_service_name,
    layers = layers,
    tables = tables,
    description = item.description,
    snippet = item.snippet
)

print(copied_item)

################################################################################
print("\nSCRIPT COMPLETE")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alternatively you can create an empty feature service and define your own layers, here's an example adding a point feature layer (&lt;A href="https://learn.finaldraftmapping.com/create-a-new-hosted-feature-service-in-arcgis-online-and-add-a-feature-layer-with-the-arcgis-api-for-python/" target="_blank" rel="noopener"&gt;blog&lt;/A&gt;), you can add multiple feature layers at once or add after the fact. You can get the field definitions from you current feature layer and define the workflow yourself to create a new feature service with your templated layers as a script.&lt;/P&gt;&lt;P&gt;All the best,&lt;/P&gt;&lt;P&gt;Glen&lt;/P&gt;</description>
    <pubDate>Thu, 04 Sep 2025 19:26:30 GMT</pubDate>
    <dc:creator>Clubdebambos</dc:creator>
    <dc:date>2025-09-04T19:26:30Z</dc:date>
    <item>
      <title>item.copy_feature_layer_collection  fails</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/item-copy-feature-layer-collection-fails/m-p/1647674#M11606</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am attempting to use the copy_feature_layer_collection&amp;nbsp; in a Notebook on ArcGIS Online (Python 3). Previously this worked fine (possibly when AGOL was using an older version of the python?). Now it fails.&lt;/P&gt;&lt;PRE&gt;newHab = habItem.copy_feature_layer_collection(service_name = habName, layers = layer_ids_h, tables = table_ids_h, folder = folderName)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;The error given looks like this:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;---------------------------------------------------------------------------&lt;/SPAN&gt;
&lt;SPAN class=""&gt;AttributeError&lt;/SPAN&gt;                            Traceback (most recent call last)
&lt;SPAN class=""&gt;/tmp/ipykernel_19/1373826970.py&lt;/SPAN&gt; in &lt;SPAN class=""&gt;&amp;lt;cell line: 0&amp;gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;()&lt;/SPAN&gt;
&lt;SPAN class=""&gt;---&amp;gt; 19&lt;/SPAN&gt; newHab &lt;SPAN class=""&gt;=&lt;/SPAN&gt; habItem&lt;SPAN class=""&gt;.&lt;/SPAN&gt;copy_feature_layer_collection&lt;SPAN class=""&gt;(&lt;/SPAN&gt;service_name &lt;SPAN class=""&gt;=&lt;/SPAN&gt; habName&lt;SPAN class=""&gt;,&lt;/SPAN&gt; layers &lt;SPAN class=""&gt;=&lt;/SPAN&gt; layer_ids_h&lt;SPAN class=""&gt;,&lt;/SPAN&gt; tables &lt;SPAN class=""&gt;=&lt;/SPAN&gt; table_ids_h&lt;SPAN class=""&gt;,&lt;/SPAN&gt; folder &lt;SPAN class=""&gt;=&lt;/SPAN&gt; folderName&lt;SPAN class=""&gt;)&lt;/SPAN&gt;

&lt;SPAN class=""&gt;/opt/conda/lib/python3.11/site-packages/arcgis/gis/__init__.py&lt;/SPAN&gt; in &lt;SPAN class=""&gt;copy_feature_layer_collection&lt;/SPAN&gt;&lt;SPAN class=""&gt;(self, service_name, layers, tables, folder, description, snippet, owner)&lt;/SPAN&gt;

&lt;SPAN class=""&gt;&amp;gt; 13848&lt;/SPAN&gt;         fs &lt;SPAN class=""&gt;=&lt;/SPAN&gt; FeatureLayerCollection&lt;SPAN class=""&gt;(&lt;/SPAN&gt;url&lt;SPAN class=""&gt;=&lt;/SPAN&gt;copied_item&lt;SPAN class=""&gt;.&lt;/SPAN&gt;url&lt;SPAN class=""&gt;,&lt;/SPAN&gt; gis&lt;SPAN class=""&gt;=&lt;/SPAN&gt;self&lt;SPAN class=""&gt;.&lt;/SPAN&gt;_gis&lt;SPAN class=""&gt;)&lt;/SPAN&gt;
&lt;SPAN class=""&gt;  13849&lt;/SPAN&gt;         fs_manager &lt;SPAN class=""&gt;=&lt;/SPAN&gt; fs&lt;SPAN class=""&gt;.&lt;/SPAN&gt;manager
&lt;SPAN class=""&gt;  13850&lt;/SPAN&gt;         add_defs &lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;{&lt;/SPAN&gt;&lt;SPAN class=""&gt;"layers"&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;[&lt;/SPAN&gt;&lt;SPAN class=""&gt;]&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt; &lt;SPAN class=""&gt;"tables"&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;[&lt;/SPAN&gt;&lt;SPAN class=""&gt;]&lt;/SPAN&gt;&lt;SPAN class=""&gt;}&lt;/SPAN&gt;

&lt;SPAN class=""&gt;AttributeError&lt;/SPAN&gt;: 'NoneType' object has no attribute 'url'&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I have tested the item and all the input parameters - all seem valid.&lt;/P&gt;&lt;P&gt;ANy ideas why this might have happended? We used this to replace the clone_items() that also changed behavior after python updates.&lt;/P&gt;&lt;P&gt;thanks!&lt;/P&gt;&lt;P&gt;Joe&lt;/P&gt;</description>
      <pubDate>Wed, 03 Sep 2025 16:56:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/item-copy-feature-layer-collection-fails/m-p/1647674#M11606</guid>
      <dc:creator>JoeNunn</dc:creator>
      <dc:date>2025-09-03T16:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: item.copy_feature_layer_collection  fails</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/item-copy-feature-layer-collection-fails/m-p/1647903#M11614</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/131962"&gt;@JoeNunn&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;How are you creating the habItem Item object? Print the habItem variable to screen and see what is returned.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Sep 2025 13:15:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/item-copy-feature-layer-collection-fails/m-p/1647903#M11614</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2025-09-04T13:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: item.copy_feature_layer_collection  fails</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/item-copy-feature-layer-collection-fails/m-p/1647966#M11616</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/417766"&gt;@Clubdebambos&lt;/a&gt;&amp;nbsp;, Its a feature layer collection with multiple layers (7 or 8 i think). Its we use it as a template:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JoeNunn_0-1756997397188.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/139881i63394AC91DEF108B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JoeNunn_0-1756997397188.png" alt="JoeNunn_0-1756997397188.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Would there be a better way to generate a new hosted feature collection from a template (say from a schema?) than attempting to duplicate an existing feature collection?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Sep 2025 14:52:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/item-copy-feature-layer-collection-fails/m-p/1647966#M11616</guid>
      <dc:creator>JoeNunn</dc:creator>
      <dc:date>2025-09-04T14:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: item.copy_feature_layer_collection  fails</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/item-copy-feature-layer-collection-fails/m-p/1648066#M11617</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/131962"&gt;@JoeNunn&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I use the same workflow but I haven't had any issues. Here's my code below. Also works fine in an ArcGIS Online Notebook.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS

################################################################################
## USER INPUT ##################################################################

new_service_name = "TESTING_DEEP_COPY"

item_id = "FS_ITEM_ID"

################################################################################
## ACCESS ARCGIS ONLINE ########################################################

agol = GIS("home")

################################################################################
## GET THE FEATURE SERVICE ITEM OBJECT #########################################

item = agol.content.get(item_id)

################################################################################
## INTEGER LISTS OF LAYERS &amp;amp; TABLES ############################################

## get the layer indexes
layers = list(range(len(item.layers)))

## get the table indexes
tables = list(range(len(item.tables)))

################################################################################
## COPY THE FEATURE SERVICE OBJECT ITEM ########################################

## copy the item - copies the shell/schema, no data is added to the layers/tables
copied_item = item.copy_feature_layer_collection(
    service_name = new_service_name,
    layers = layers,
    tables = tables,
    description = item.description,
    snippet = item.snippet
)

print(copied_item)

################################################################################
print("\nSCRIPT COMPLETE")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alternatively you can create an empty feature service and define your own layers, here's an example adding a point feature layer (&lt;A href="https://learn.finaldraftmapping.com/create-a-new-hosted-feature-service-in-arcgis-online-and-add-a-feature-layer-with-the-arcgis-api-for-python/" target="_blank" rel="noopener"&gt;blog&lt;/A&gt;), you can add multiple feature layers at once or add after the fact. You can get the field definitions from you current feature layer and define the workflow yourself to create a new feature service with your templated layers as a script.&lt;/P&gt;&lt;P&gt;All the best,&lt;/P&gt;&lt;P&gt;Glen&lt;/P&gt;</description>
      <pubDate>Thu, 04 Sep 2025 19:26:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/item-copy-feature-layer-collection-fails/m-p/1648066#M11617</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2025-09-04T19:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: item.copy_feature_layer_collection  fails</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/item-copy-feature-layer-collection-fails/m-p/1648169#M11618</link>
      <description>&lt;P&gt;Thanks Glen - maybe its the item itself causing the issue? I will try it on a simpler version maybe. Anyway this proves the workflow works.&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Joe&lt;/P&gt;</description>
      <pubDate>Fri, 05 Sep 2025 08:35:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/item-copy-feature-layer-collection-fails/m-p/1648169#M11618</guid>
      <dc:creator>JoeNunn</dc:creator>
      <dc:date>2025-09-05T08:35:04Z</dc:date>
    </item>
  </channel>
</rss>

