I would like to use ArcGIS Python API (v. 1.4.1) to copy the operational layers from one map to another in the same 10.6 Portal (for a development map / production map environment where I make changes to the development maps' symbology, layers, popups, etc., and then just copy the entire operational layers object to the production map), but I can't get it to work (even though it worked on a previous version of the API / previous version of Portal).
Here is my old code, which worked in a previous version.
In this version, the code successfully runs, but the destination map isn't changed.
<SPAN class="keyword token">from</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>gis <SPAN class="keyword token">import</SPAN> GIS
<SPAN class="keyword token">from</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>gis <SPAN class="keyword token">import</SPAN> Item
<SPAN class="keyword token">import</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>mapping
portal <SPAN class="operator token">=</SPAN> GIS<SPAN class="punctuation token">(</SPAN><SPAN class="string token"><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fportalurl%2Fwebcontext" target="_blank">https://portalurl/webcontext</A><SPAN>"</SPAN></SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"username"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"password"</SPAN><SPAN class="punctuation token">,</SPAN> verify_cert<SPAN class="operator token">=</SPAN><SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">)</SPAN>
srcMap <SPAN class="operator token">=</SPAN> Item<SPAN class="punctuation token">(</SPAN>portal<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"5959197ba01748ccb51cf097597b4cf4"</SPAN><SPAN class="punctuation token">)</SPAN>
destMap<SPAN class="operator token">=</SPAN> Item<SPAN class="punctuation token">(</SPAN>portal<SPAN class="punctuation token">,</SPAN><SPAN class="string token">"e326e343d5aa45668a448e54acc4d06d"</SPAN><SPAN class="punctuation token">)</SPAN>
opsLayers <SPAN class="operator token">=</SPAN> srcMap<SPAN class="punctuation token">.</SPAN>get_data<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">'operationalLayers'</SPAN><SPAN class="punctuation token">]</SPAN>
mapDestObj <SPAN class="operator token">=</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>WebMap<SPAN class="punctuation token">(</SPAN>destMap<SPAN class="punctuation token">)</SPAN>
mapDestObj<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'operationalLayers'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> opsLayers
mapDestObj<SPAN class="punctuation token">.</SPAN>update<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
I've also followed instructions located at Using and updating GIS content | ArcGIS for Developers , but that doesn't seem to work either.
mapDestObj has a layers attribute, but mapDestObj.layers = opsLayers throws an AttributeError (can't set attribute)
I've also tried the following: which successfully updates the mapDestObj.layers attribute, but doesn't save the map when I run the update command.
<SPAN class="keyword token">for</SPAN> index<SPAN class="punctuation token">,</SPAN> layer <SPAN class="keyword token">in</SPAN> enumerate<SPAN class="punctuation token">(</SPAN>mapDestObj<SPAN class="punctuation token">.</SPAN>layers<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
mapDestObj<SPAN class="punctuation token">.</SPAN>layers<SPAN class="punctuation token">[</SPAN>index<SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> opsLayers<SPAN class="punctuation token">[</SPAN>index<SPAN class="punctuation token">]</SPAN>
webMapObj<SPAN class="punctuation token">.</SPAN>update<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Does anyone have a working prototype for this workflow?