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.
from arcgis.gis import GIS
from arcgis.gis import Item
portal = GIS("https://portalurl/webcontext", "username","password", verify_cert=False)
srcMap = Item(portal, "5959197ba01748ccb51cf097597b4cf4")
opsLayers = srcMap.get_data()['operationalLayers']
mapDestObj = arcgis.mapping.WebMap(destMap)
mapDestObj['operationalLayers'] = opsLayers
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.
for index, layer in enumerate(mapDestObj.layers):
mapDestObj.layers[index] = opsLayers[index]
Does anyone have a working prototype for this workflow?