<?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: Clone items between envs is missing child layers in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/clone-items-between-envs-is-missing-child-layers/m-p/1568571#M73341</link>
    <description>&lt;P&gt;I never did get cloning to work properly with map name, but if I pass the item ID, it works most of the time.&lt;/P&gt;&lt;P&gt;have less going on than your code, but I just use a Notebook in Pro to clone one item at a time as needed.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RhettZufelt_0-1734123623638.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/121762i55A0743F7797863D/image-size/large?v=v2&amp;amp;px=999" role="button" title="RhettZufelt_0-1734123623638.png" alt="RhettZufelt_0-1734123623638.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As long as I'm connected to the source and target GIS's with admin user, this will normally copy the App/Map/HFS's included.&lt;/P&gt;&lt;P&gt;Of course, doesn't always work and I just chalk that up to the ESRI uncertainty principle &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;In case this helps somehow,&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 13 Dec 2024 21:03:43 GMT</pubDate>
    <dc:creator>RhettZufelt</dc:creator>
    <dc:date>2024-12-13T21:03:43Z</dc:date>
    <item>
      <title>Clone items between envs is missing child layers</title>
      <link>https://community.esri.com/t5/python-questions/clone-items-between-envs-is-missing-child-layers/m-p/1568420#M73339</link>
      <description>&lt;P&gt;I am trying to clone hosted items from one env to another (dev to prod, etc). I have spent alot of time with&amp;nbsp;&lt;A href="https://developers.arcgis.com/python/latest/guide/cloning-content/" target="_self"&gt;clone docs&lt;/A&gt;&amp;nbsp; and the&amp;nbsp;&lt;A href="https://developers.arcgis.com/python/latest/api-reference/arcgis.gis.toc.html#arcgis.gis.ContentManager.clone_items" target="_self"&gt;clone_items&lt;/A&gt;&amp;nbsp;documentation. Nothing is cloning as it should.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried everything locally as well as inside of ArcGis pro w notebooks, just in case.&lt;/P&gt;&lt;P&gt;What I've tried:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Using the clone_items API above as directed.&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;From the &lt;A href="https://developers.arcgis.com/python/latest/samples/clone-portal-users-groups-and-content-rn/#copy-items" target="_self"&gt;ArcGis Py docs samples&lt;/A&gt;&amp;nbsp;I've tried the&amp;nbsp;&lt;A href="https://github.com/Esri/arcgis-python-api" target="_self"&gt;sample github code&lt;/A&gt;&amp;nbsp;for cloning entire portals. It uses a &lt;A href="https://developers.arcgis.com/python/latest/api-reference/arcgis.gis.toc.html#arcgis.gis._impl._content_manager.Folder" target="_self"&gt;Folder add&lt;/A&gt;&amp;nbsp;function.&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&amp;nbsp;Variation on #1: using content.get() on a web map and then trying to extract the layers and then individually clone each.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Nothing has worked.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;For #1:&lt;/STRONG&gt; When I copy from one env to another for large items, web map for example, the child layers do not get copied with. Either they are broken or they are still attached the previous env. The code below copies over the web map but the inside layers do not work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;&amp;gt;&amp;gt;&amp;gt; src=app.login(app.username, app.password, app.source)
logged in
&amp;gt;&amp;gt;&amp;gt; trg = app.login(app.username2, app.password2, app.target)
logged in
&amp;gt;&amp;gt;&amp;gt; item = src.content.get(app.WEBMAP_012_H1_Map)
&amp;gt;&amp;gt; cloned = trg.content.clone_items(items=[item], search_existing_items=False, folder="TestFolder", copy_data=True)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The layers and what happens when I open one in target env:&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-12-13 081229.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/121718i33339E73C69BBC80/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2024-12-13 081229.png" alt="Screenshot 2024-12-13 081229.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-12-13 081145.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/121719i2EE6AC89928018F7/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2024-12-13 081145.png" alt="Screenshot 2024-12-13 081145.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;For #2:&amp;nbsp;&lt;/STRONG&gt;Similar to process #1 based on&amp;nbsp;&lt;A href="https://github.com/Esri/arcgis-python-api/blob/master/samples/03_org_administrators/AdminClonePortal/clone_portal.py" target="_blank" rel="noopener"&gt;https://github.com/Esri/arcgis-python-api/blob/master/samples/03_org_administrators/AdminClonePortal/clone_portal.py&lt;/A&gt;&amp;nbsp;but it takes an items_properties param, which the code sample gives a dict. This also copies the web map (or whatever parent) and not the layers. It's broken in the same way as #1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;item = src.content.get(WEBMAP_012_H1_Map)
folder = trg.content.folders.get() #root folder
copied_item = folder.add(item_properties, data_file)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;For #3:&amp;nbsp;&lt;/STRONG&gt;I don't know how to extract the layers in order to send each individually.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;&amp;gt;&amp;gt;&amp;gt; item
&amp;lt;Item title:"011_WP_Image_Map" type:Web Map owner:me&amp;gt;
&amp;gt;&amp;gt;&amp;gt; item.layers
KeyError: 'layers'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From this &lt;A href="https://teams.microsoft.com/l/message/19:084b2e15-8c21-4dfa-bc5f-dc2bf3f0ae5a_55df5b99-8652-492f-b46c-3622f220f7f6@unq.gbl.spaces/1733855316502?context=%7B%22contextType%22%3A%22chat%22%7D" target="_self"&gt;video&lt;/A&gt;&amp;nbsp;there is an idea of building a WebMap object. The WebMap module is broken and will not load so I tried plain&amp;nbsp;&lt;A href="https://developers.arcgis.com/python/latest/guide/working-with-web-maps-and-web-scenes/#creating-a-map-object" target="_self"&gt;Map&lt;/A&gt;&amp;nbsp;instead. Using this it is possible to see the layers, but they are not compatible with the API. So if this method is possible, I don't know how to get the layers into a working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;&amp;gt;&amp;gt;&amp;gt; item
&amp;lt;Item title:"011_WP_Image_Map" type:Web Map owner:me&amp;gt;
&amp;gt;&amp;gt;&amp;gt; from arcgis.map import Map
&amp;gt;&amp;gt;&amp;gt; m = Map(item=item)
&amp;gt;&amp;gt;&amp;gt; m
Map(extent={'spatialReference': {'latestWkid': 3857, 'wkid': 102100}, 'xmax': -8856055.01662957, 'xmin': -8857992.217565008, 'ymax': 5414849.335929911, 'ymin': 5413334.927307139})
[&amp;lt;MapImageLayer 
&amp;gt;&amp;gt;&amp;gt; m.content.layers
url:"https://myUrl.net/server/rest/services/011/001_June_24__Vegetation_Condition_Index_HIL/MapServer"&amp;gt;, &amp;lt;MapImageLayer url:"https://myUrl.net/server/rest/services/011/011_WP_June_24__EVI_HIL/MapServer"&amp;gt;]
&amp;gt;&amp;gt;&amp;gt; trg.content.clone_items(items=[m.content.layers[0]], search_existing_items=False, folder="TestFolder", copy_data=True)
TypeError: 'MapImageLayer' object is not subscriptable&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; How the heck does cloning work in Esri?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2024 14:58:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clone-items-between-envs-is-missing-child-layers/m-p/1568420#M73339</guid>
      <dc:creator>chris_del101</dc:creator>
      <dc:date>2024-12-13T14:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: Clone items between envs is missing child layers</title>
      <link>https://community.esri.com/t5/python-questions/clone-items-between-envs-is-missing-child-layers/m-p/1568571#M73341</link>
      <description>&lt;P&gt;I never did get cloning to work properly with map name, but if I pass the item ID, it works most of the time.&lt;/P&gt;&lt;P&gt;have less going on than your code, but I just use a Notebook in Pro to clone one item at a time as needed.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RhettZufelt_0-1734123623638.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/121762i55A0743F7797863D/image-size/large?v=v2&amp;amp;px=999" role="button" title="RhettZufelt_0-1734123623638.png" alt="RhettZufelt_0-1734123623638.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As long as I'm connected to the source and target GIS's with admin user, this will normally copy the App/Map/HFS's included.&lt;/P&gt;&lt;P&gt;Of course, doesn't always work and I just chalk that up to the ESRI uncertainty principle &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;In case this helps somehow,&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2024 21:03:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clone-items-between-envs-is-missing-child-layers/m-p/1568571#M73341</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2024-12-13T21:03:43Z</dc:date>
    </item>
    <item>
      <title>Re: Clone items between envs is missing child layers</title>
      <link>https://community.esri.com/t5/python-questions/clone-items-between-envs-is-missing-child-layers/m-p/1568842#M73344</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/852729"&gt;@chris_del101&lt;/a&gt;&amp;nbsp;I don't seem to have much luck with cloning either.&amp;nbsp; Check out these &lt;A href="https://community.esri.com/t5/arcgis-enterprise-documents/migrate-content-for-arcgis-enterprise-arcgis/ta-p/1365455" target="_self"&gt;tools&lt;/A&gt;.&amp;nbsp; They will allow you to migrate hosted feature services, web maps, web apps, dashboards, and story maps from one environment to another.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2024 14:20:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clone-items-between-envs-is-missing-child-layers/m-p/1568842#M73344</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2024-12-16T14:20:04Z</dc:date>
    </item>
  </channel>
</rss>

