<?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 'NoneType&amp;quot; Error when adding layer to WebMap using Python API in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/nonetype-quot-error-when-adding-layer-to-webmap/m-p/764307#M479</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Trying to add a layer (Portal item) to a webmap. The &lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.mapping.toc.html#arcgis.mapping.WebMap.add_layer" rel="nofollow noopener noreferrer" target="_blank"&gt;ESRI&amp;nbsp;example&lt;/A&gt;&amp;nbsp;for this I'm looking at is very simple:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;streets_item &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; gis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;content&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;search&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"LA Streets"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Map Service"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

wm &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; WebMap&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;  &lt;SPAN class="comment token"&gt;# create an empty web map with a default basemap&lt;/SPAN&gt;
wm&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;add_layer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;streets_item&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Okay, so I have a web map that's not empty that I created like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;type&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;target_item&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcgis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; WebMap
web_map_obj &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; WebMap&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;target_item&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;type&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;web_map_obj&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍

&lt;SPAN class="comment token"&gt;#&amp;gt;&amp;gt;&amp;gt; &amp;lt;class 'arcgis.gis.Item'&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;#&amp;gt;&amp;gt;&amp;gt; &amp;lt;class 'arcgis.mapping._types.WebMap'&amp;gt;&lt;/SPAN&gt;
‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The print() statements are only there to assure myself that I'm actually looking at items on and not itemId's or who knows what. So I have a legit Python web map based on on a web map item in Portal. As a check, I do...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;web_map_obj&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;layers

&lt;SPAN class="comment token"&gt;# prints out all the layers (map image layers) that nelong to the Portal web map&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;So now, I want to add another layer&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;newLayer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; gis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;content&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;search&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;query &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"new layer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# again just checking this is what I expect&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;type&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;newLayer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

web_map_obj&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;add_layer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;newLayer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Well, this bombs...&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&amp;lt;class 'arcgis.gis.Item'&amp;gt;

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&amp;lt;ipython-input-191-62f982ec1c55&amp;gt; in &amp;lt;module&amp;gt;
     13     # again just checking this is what I expect
     14     print(type(newLayer))
---&amp;gt; 15     web_map_obj.add_layer(newLayer)

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\mapping\_types.py in add_layer(self, layer, options)
    323 
    324                 for lyr in layer.layers:  # recurse - works for all.
--&amp;gt; 325                     self.add_layer(lyr, options)
    326                 return True  # end add_layer execution after iterating through each layer.
    327             else:

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\mapping\_types.py in add_layer(self, layer, options)
    510                         fields_list = layer.properties.layerDefinition.fields
    511 
--&amp;gt; 512             for f in fields_list:
    513                 if isinstance(f, dict) or isinstance(f, PropertyMap):
    514                     field_dict = {'fieldName': f['name'],

TypeError: 'NoneType' object is not iterable
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What's wrong with what I'm doing? I realize there is also&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.Layer" rel="nofollow noopener noreferrer" target="_blank"&gt;&amp;nbsp;&lt;CODE class=""&gt;arcgis.gis.&lt;/CODE&gt;&lt;/A&gt;&lt;CODE class=""&gt;&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.Layer" rel="nofollow noopener noreferrer" target="_blank"&gt;Layer&lt;/A&gt;. &lt;SPAN style="color: #3d3d3d; font-weight: 400;"&gt;Do I first need to create a Layer from the item and then add that to the web map maybe?&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 08:28:14 GMT</pubDate>
    <dc:creator>Arne_Gelfert</dc:creator>
    <dc:date>2021-12-12T08:28:14Z</dc:date>
    <item>
      <title>'NoneType" Error when adding layer to WebMap using Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/nonetype-quot-error-when-adding-layer-to-webmap/m-p/764307#M479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Trying to add a layer (Portal item) to a webmap. The &lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.mapping.toc.html#arcgis.mapping.WebMap.add_layer" rel="nofollow noopener noreferrer" target="_blank"&gt;ESRI&amp;nbsp;example&lt;/A&gt;&amp;nbsp;for this I'm looking at is very simple:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;streets_item &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; gis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;content&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;search&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"LA Streets"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Map Service"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

wm &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; WebMap&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;  &lt;SPAN class="comment token"&gt;# create an empty web map with a default basemap&lt;/SPAN&gt;
wm&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;add_layer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;streets_item&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Okay, so I have a web map that's not empty that I created like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;type&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;target_item&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcgis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; WebMap
web_map_obj &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; WebMap&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;target_item&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;type&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;web_map_obj&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍

&lt;SPAN class="comment token"&gt;#&amp;gt;&amp;gt;&amp;gt; &amp;lt;class 'arcgis.gis.Item'&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;#&amp;gt;&amp;gt;&amp;gt; &amp;lt;class 'arcgis.mapping._types.WebMap'&amp;gt;&lt;/SPAN&gt;
‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The print() statements are only there to assure myself that I'm actually looking at items on and not itemId's or who knows what. So I have a legit Python web map based on on a web map item in Portal. As a check, I do...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;web_map_obj&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;layers

&lt;SPAN class="comment token"&gt;# prints out all the layers (map image layers) that nelong to the Portal web map&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;So now, I want to add another layer&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;newLayer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; gis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;content&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;search&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;query &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"new layer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# again just checking this is what I expect&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;type&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;newLayer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

web_map_obj&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;add_layer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;newLayer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Well, this bombs...&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&amp;lt;class 'arcgis.gis.Item'&amp;gt;

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&amp;lt;ipython-input-191-62f982ec1c55&amp;gt; in &amp;lt;module&amp;gt;
     13     # again just checking this is what I expect
     14     print(type(newLayer))
---&amp;gt; 15     web_map_obj.add_layer(newLayer)

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\mapping\_types.py in add_layer(self, layer, options)
    323 
    324                 for lyr in layer.layers:  # recurse - works for all.
--&amp;gt; 325                     self.add_layer(lyr, options)
    326                 return True  # end add_layer execution after iterating through each layer.
    327             else:

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\mapping\_types.py in add_layer(self, layer, options)
    510                         fields_list = layer.properties.layerDefinition.fields
    511 
--&amp;gt; 512             for f in fields_list:
    513                 if isinstance(f, dict) or isinstance(f, PropertyMap):
    514                     field_dict = {'fieldName': f['name'],

TypeError: 'NoneType' object is not iterable
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What's wrong with what I'm doing? I realize there is also&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.Layer" rel="nofollow noopener noreferrer" target="_blank"&gt;&amp;nbsp;&lt;CODE class=""&gt;arcgis.gis.&lt;/CODE&gt;&lt;/A&gt;&lt;CODE class=""&gt;&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.Layer" rel="nofollow noopener noreferrer" target="_blank"&gt;Layer&lt;/A&gt;. &lt;SPAN style="color: #3d3d3d; font-weight: 400;"&gt;Do I first need to create a Layer from the item and then add that to the web map maybe?&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:28:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/nonetype-quot-error-when-adding-layer-to-webmap/m-p/764307#M479</guid>
      <dc:creator>Arne_Gelfert</dc:creator>
      <dc:date>2021-12-12T08:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: 'NoneType" Error when adding layer to WebMap using Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/nonetype-quot-error-when-adding-layer-to-webmap/m-p/764308#M480</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So it looks like the following works:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;newLayer_item &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; gis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;content&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;search&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;query &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"new layer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;###############################################&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# the following line is new and made this work&lt;/SPAN&gt;
newLayer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcgis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;gis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Layer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;newLayer_item&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;###############################################&lt;/SPAN&gt;
web_map_obj&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;add_layer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;newLayer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Now I can see the new layers with&lt;/SPAN&gt;
web_map_obj&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;layers‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyone know if the above referenced original ESRI example&amp;nbsp;will ever work and if&amp;nbsp;I was doing something wrong?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:28:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/nonetype-quot-error-when-adding-layer-to-webmap/m-p/764308#M480</guid>
      <dc:creator>Arne_Gelfert</dc:creator>
      <dc:date>2021-12-12T08:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: 'NoneType" Error when adding layer to WebMap using Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/nonetype-quot-error-when-adding-layer-to-webmap/m-p/764309#M481</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Where are you executing your code from, Python interactive windows in ArcGIS Pro, Python command prompt, Jupyter notebook?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2020 17:44:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/nonetype-quot-error-when-adding-layer-to-webmap/m-p/764309#M481</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-07-20T17:44:26Z</dc:date>
    </item>
    <item>
      <title>Re: 'NoneType" Error when adding layer to WebMap using Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/nonetype-quot-error-when-adding-layer-to-webmap/m-p/764310#M482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jupyter Notebooks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2020 18:30:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/nonetype-quot-error-when-adding-layer-to-webmap/m-p/764310#M482</guid>
      <dc:creator>Arne_Gelfert</dc:creator>
      <dc:date>2020-07-20T18:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: 'NoneType" Error when adding layer to WebMap using Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/nonetype-quot-error-when-adding-layer-to-webmap/m-p/764311#M483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Regarding newLayer_item, what exactly is it?&amp;nbsp; I get the Esri examples to work in Jupyter, after a minor change to search outside my org, so I am wondering about your layer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2020 20:48:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/nonetype-quot-error-when-adding-layer-to-webmap/m-p/764311#M483</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-07-20T20:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: 'NoneType" Error when adding layer to WebMap using Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/nonetype-quot-error-when-adding-layer-to-webmap/m-p/764312#M484</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;NewLayer is&amp;nbsp;a&amp;nbsp;Portal item that&amp;nbsp;references a&amp;nbsp;Map Service on&amp;nbsp;our&amp;nbsp;federated GIS Server. Where this all started was when I looked into copying a web map item from one Portal environment (Test) to another (Prod) and then trying to replace some map services&amp;nbsp;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2020 20:59:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/nonetype-quot-error-when-adding-layer-to-webmap/m-p/764312#M484</guid>
      <dc:creator>Arne_Gelfert</dc:creator>
      <dc:date>2020-07-20T20:59:58Z</dc:date>
    </item>
    <item>
      <title>Re: 'NoneType" Error when adding layer to WebMap using Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/nonetype-quot-error-when-adding-layer-to-webmap/m-p/764313#M485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since the Esri examples work for me in Jupyter, and I can't test directly using your data, I don't have any other suggestions/ideas at this point.&amp;nbsp; Maybe a Pro version thing.&amp;nbsp; What version of Pro are you running?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2020 22:09:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/nonetype-quot-error-when-adding-layer-to-webmap/m-p/764313#M485</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-07-20T22:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: 'NoneType" Error when adding layer to WebMap using Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/nonetype-quot-error-when-adding-layer-to-webmap/m-p/764314#M486</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is&amp;nbsp;Pro 2.5... I might try upgrading or&amp;nbsp;at checking which version of arcgis&amp;nbsp;modules my conda environment is using.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2020 22:26:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/nonetype-quot-error-when-adding-layer-to-webmap/m-p/764314#M486</guid>
      <dc:creator>Arne_Gelfert</dc:creator>
      <dc:date>2020-07-20T22:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: 'NoneType" Error when adding layer to WebMap using Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/nonetype-quot-error-when-adding-layer-to-webmap/m-p/764315#M487</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Turns out the syntax of the ESRI example works when adding an item (as layer) to web map using add_layer() works when it was created&amp;nbsp;&lt;SPAN&gt;as empty new web map&amp;nbsp;like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-javascript line-numbers"&gt;&lt;CODE&gt;webmap &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;‍Webmap&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But not when the web map was created off another item and already has some layers...&lt;/P&gt;&lt;PRE class="language-javascript line-numbers"&gt;&lt;CODE&gt;webmap &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Webmap&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;item&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This may be explained somewhere in ESRI documentation. Good to know!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jul 2020 16:04:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/nonetype-quot-error-when-adding-layer-to-webmap/m-p/764315#M487</guid>
      <dc:creator>Arne_Gelfert</dc:creator>
      <dc:date>2020-07-23T16:04:16Z</dc:date>
    </item>
  </channel>
</rss>

