There are several threads on here that have gotten me this far, but I've still not found any solid documentation about what needs to be supplied to the JSON dictionary in order to properly update it. Note: I can get this to work when there is only one layer in the feature layer/feature collection. I'm just stuck.
Here is my code so far.
<SPAN class="string token">""</SPAN>"
<SPAN class="comment token">#Import Modules</SPAN>
<SPAN class="keyword token">import</SPAN> copy<SPAN class="punctuation token">,</SPAN>json
<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>mapping <SPAN class="keyword token">import</SPAN> WebMap
<SPAN class="comment token">#Log into ArcGIS Enterprise</SPAN>
gis <SPAN class="operator token">=</SPAN> GIS<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"https://awesomeportalname.com/portal"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"DougMcGrave"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"a1ntL!FeGr@nd!"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Logged in as: "</SPAN> <SPAN class="operator token">+</SPAN> gis<SPAN class="punctuation token">.</SPAN>properties<SPAN class="punctuation token">.</SPAN>user<SPAN class="punctuation token">.</SPAN>username<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#Retrieve NortheastFieldData web map</SPAN>
webMapSearch <SPAN class="operator token">=</SPAN> gis<SPAN class="punctuation token">.</SPAN>content<SPAN class="punctuation token">.</SPAN>search<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"title: NortheastFieldData2"</SPAN><SPAN class="punctuation token">,</SPAN>item_type <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Web Map"</SPAN><SPAN class="punctuation token">)</SPAN>
sourceWebMap<SPAN class="operator token">=</SPAN> webMapSearch<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="comment token">#itemID = webMapTest.id</SPAN>
<SPAN class="comment token">#print(itemID)</SPAN>
<SPAN class="comment token">#Read the web map as a WebMap object</SPAN>
webMapObject <SPAN class="operator token">=</SPAN> WebMap<SPAN class="punctuation token">(</SPAN>sourceWebMap<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#Create a copy of the web map with a new title</SPAN>
webmap_item_properties <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN><SPAN class="string token">'title'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'TestCopyThis'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'snippet'</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="string token">'testcopydis'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'tags'</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="string token">'Test'</SPAN><SPAN class="punctuation token">}</SPAN>
webMapObject<SPAN class="punctuation token">.</SPAN>save<SPAN class="punctuation token">(</SPAN>webmap_item_properties<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#Retrieve new web map</SPAN>
newWebMapSearch <SPAN class="operator token">=</SPAN> gis<SPAN class="punctuation token">.</SPAN>content<SPAN class="punctuation token">.</SPAN>search<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"title: TestCopyThis"</SPAN><SPAN class="punctuation token">,</SPAN>item_type <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Web Map"</SPAN><SPAN class="punctuation token">)</SPAN>
newWebMap <SPAN class="operator token">=</SPAN> newWebMapSearch<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">for</SPAN> layer <SPAN class="keyword token">in</SPAN> newWebMap<SPAN class="punctuation token">.</SPAN>layers<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>layer<SPAN class="punctuation token">.</SPAN>title<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#Extract JSON from webmap</SPAN>
pubMapJson <SPAN class="operator token">=</SPAN> newWebMap<SPAN class="punctuation token">.</SPAN>get_data<SPAN class="punctuation token">(</SPAN>try_json<SPAN class="operator token">=</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN>
jsonCopy <SPAN class="operator token">=</SPAN> copy<SPAN class="punctuation token">.</SPAN>deepcopy<SPAN class="punctuation token">(</SPAN>pubMapJson<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#Layers in web map which need filter applied</SPAN>
layersList <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'NortheastCruisePoints'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'NortheastClientsCollector - NortheastPoints'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'NortheastClientsCollector - NortheastPoints'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'NortheastClientsCollector - NortheastLines'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'NortheastClientsCollector - NortheastStands'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'NortheastClientsCollector - Harvest Operations Status'</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="comment token">#Filter to be applied</SPAN>
lyrFilter <SPAN class="operator token">=</SPAN> <SPAN class="string token">"LVI_CODE = '{0}'"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"7532"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#Extract JSON from webmap and create a copy</SPAN>
pubMapJson <SPAN class="operator token">=</SPAN> newWebMap<SPAN class="punctuation token">.</SPAN>get_data<SPAN class="punctuation token">(</SPAN>try_json<SPAN class="operator token">=</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN>
jsonCopy <SPAN class="operator token">=</SPAN> copy<SPAN class="punctuation token">.</SPAN>deepcopy<SPAN class="punctuation token">(</SPAN>pubMapJson<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#Loop through each layer</SPAN>
<SPAN class="keyword token">for</SPAN> lyr <SPAN class="keyword token">in</SPAN> layersList<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="string token">'layerDefinition'</SPAN> <SPAN class="keyword token">in</SPAN> lyr<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>lyr<SPAN class="punctuation token">)</SPAN>
jsonCopy<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'operationalLayers'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">'layerDefinition'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">'definitionExpression'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="operator token">=</SPAN>lyrFilter
<SPAN class="comment token">#Update JSON</SPAN>
newWebMap<SPAN class="punctuation token">.</SPAN>update<SPAN class="punctuation token">(</SPAN>item_properties<SPAN class="operator token">=</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">'text'</SPAN><SPAN class="punctuation token">:</SPAN>json<SPAN class="punctuation token">.</SPAN>dumps<SPAN class="punctuation token">(</SPAN>jsonCopy<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></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>No errors are given and the JSON update returns 'True'