<?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 ValidationError - Assigning a Web Map to a Variable in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/validationerror-assigning-a-web-map-to-a-variable/m-p/1578957#M11091</link>
    <description>&lt;P&gt;Hey all,&lt;/P&gt;&lt;P&gt;I have created a script that goes through my web maps with offline areas and updates them all for the organisation. It worked fine for a couple of web maps I had made for testing but then when I try to run the script with web maps that are in use, I am running into this '&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;ValidationError&lt;/SPAN&gt;: 108 validation errors for Webmap&lt;/PRE&gt;&lt;P&gt;Out of the 52 web maps, only a small portion don't have the error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for wm_item in wm_items:
    print (wm_item)
    # access the Map object
    wm_obj = Map(item=wm_item)
    # this displays what the existing offline areas are and what items are part of each area
    for oma_item in wm_obj.offline_areas.list():
        print(f"Web Map: {wm_item.title}\n{oma_item.title} offline area shares the `Area2Package` relationship with: \n{'-' * 50}")
        for rel_item in oma_item.related_items('Area2Package', 'forward'):
            print(f"{' '*2}{rel_item.title:55}\n{' '*4}{rel_item.type}")
        print("\n")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The issue is when trying to assign the web map object in line 4 i get the following, I didnt copy all of it as it continues for a while:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;---------------------------------------------------------------------------
ValidationError                           Traceback (most recent call last)
Cell In[6], line 6
      4 print (wm_item)
      5 # access the Map object
----&amp;gt; 6 wm_obj = Map(item=wm_item)
      7 # this displays what the existing offline areas are and what items are part of each area
      8 for oma_item in wm_obj.offline_areas.list():

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\map\map_widget.py:254, in Map.__init__(self, location, item, gis, **kwargs)
    250 self._helper._setup_gis_properties(gis)
    252 # Set up the map that will be used
    253 # either existing or new instance
--&amp;gt; 254 self._setup_webmap_properties(item)
    256 # Assign the definition to helper class. This is the pydantic dataclass.
    257 self._helper._set_widget_definition(self._webmap)

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\map\map_widget.py:402, in Map._setup_webmap_properties(self, item)
    399 data = self._fix_basemap_data(data)
    401 # Use pydantic dataclass from webmap_spec
--&amp;gt; 402 self._webmap = ws.Webmap(**data)
    404 # For bookmarks class
    405 if self._webmap.bookmarks is None:

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\pydantic\main.py:164, in BaseModel.__init__(__pydantic_self__, **data)
    162 # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
    163 __tracebackhide__ = True
--&amp;gt; 164 __pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)

ValidationError: 108 validation errors for Webmap
operationalLayers.2.AnnotationLayerArcGISAnnotationLayer.layerType
  Input should be 'ArcGISAnnotationLayer' [type=literal_error, input_value='GroupLayer', input_type=str]
    For further information visit https://errors.pydantic.dev/2.4/v/literal_error
operationalLayers.2.CatalogLayerCatalogLayer.layerType
  Input should be 'CatalogLayer' [type=literal_error, input_value='GroupLayer', input_type=str]
    For further information visit https://errors.pydantic.dev/2.4/v/literal_error
operationalLayers.2.CSVLayerCSV.layerType
  Input should be 'CSV' [type=literal_error, input_value='GroupLayer', input_type=str]
    For further information visit https://errors.pydantic.dev/2.4/v/literal_error
operationalLayers.2.CSVLayerCSV.url&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The successful processed web maps output the following:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tiztrain_0-1737882368684.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/124051i1D87CEB4B77B9E72/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tiztrain_0-1737882368684.png" alt="tiztrain_0-1737882368684.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have been trying to look at what is the difference with the web maps that work fine and what is the difference with the ones that does but can't figure it out. Does anyone have any advice here?&lt;/P&gt;</description>
    <pubDate>Sun, 26 Jan 2025 10:14:03 GMT</pubDate>
    <dc:creator>tiztrain</dc:creator>
    <dc:date>2025-01-26T10:14:03Z</dc:date>
    <item>
      <title>ValidationError - Assigning a Web Map to a Variable</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/validationerror-assigning-a-web-map-to-a-variable/m-p/1578957#M11091</link>
      <description>&lt;P&gt;Hey all,&lt;/P&gt;&lt;P&gt;I have created a script that goes through my web maps with offline areas and updates them all for the organisation. It worked fine for a couple of web maps I had made for testing but then when I try to run the script with web maps that are in use, I am running into this '&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;ValidationError&lt;/SPAN&gt;: 108 validation errors for Webmap&lt;/PRE&gt;&lt;P&gt;Out of the 52 web maps, only a small portion don't have the error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for wm_item in wm_items:
    print (wm_item)
    # access the Map object
    wm_obj = Map(item=wm_item)
    # this displays what the existing offline areas are and what items are part of each area
    for oma_item in wm_obj.offline_areas.list():
        print(f"Web Map: {wm_item.title}\n{oma_item.title} offline area shares the `Area2Package` relationship with: \n{'-' * 50}")
        for rel_item in oma_item.related_items('Area2Package', 'forward'):
            print(f"{' '*2}{rel_item.title:55}\n{' '*4}{rel_item.type}")
        print("\n")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The issue is when trying to assign the web map object in line 4 i get the following, I didnt copy all of it as it continues for a while:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;---------------------------------------------------------------------------
ValidationError                           Traceback (most recent call last)
Cell In[6], line 6
      4 print (wm_item)
      5 # access the Map object
----&amp;gt; 6 wm_obj = Map(item=wm_item)
      7 # this displays what the existing offline areas are and what items are part of each area
      8 for oma_item in wm_obj.offline_areas.list():

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\map\map_widget.py:254, in Map.__init__(self, location, item, gis, **kwargs)
    250 self._helper._setup_gis_properties(gis)
    252 # Set up the map that will be used
    253 # either existing or new instance
--&amp;gt; 254 self._setup_webmap_properties(item)
    256 # Assign the definition to helper class. This is the pydantic dataclass.
    257 self._helper._set_widget_definition(self._webmap)

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\map\map_widget.py:402, in Map._setup_webmap_properties(self, item)
    399 data = self._fix_basemap_data(data)
    401 # Use pydantic dataclass from webmap_spec
--&amp;gt; 402 self._webmap = ws.Webmap(**data)
    404 # For bookmarks class
    405 if self._webmap.bookmarks is None:

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\pydantic\main.py:164, in BaseModel.__init__(__pydantic_self__, **data)
    162 # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
    163 __tracebackhide__ = True
--&amp;gt; 164 __pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)

ValidationError: 108 validation errors for Webmap
operationalLayers.2.AnnotationLayerArcGISAnnotationLayer.layerType
  Input should be 'ArcGISAnnotationLayer' [type=literal_error, input_value='GroupLayer', input_type=str]
    For further information visit https://errors.pydantic.dev/2.4/v/literal_error
operationalLayers.2.CatalogLayerCatalogLayer.layerType
  Input should be 'CatalogLayer' [type=literal_error, input_value='GroupLayer', input_type=str]
    For further information visit https://errors.pydantic.dev/2.4/v/literal_error
operationalLayers.2.CSVLayerCSV.layerType
  Input should be 'CSV' [type=literal_error, input_value='GroupLayer', input_type=str]
    For further information visit https://errors.pydantic.dev/2.4/v/literal_error
operationalLayers.2.CSVLayerCSV.url&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The successful processed web maps output the following:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tiztrain_0-1737882368684.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/124051i1D87CEB4B77B9E72/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tiztrain_0-1737882368684.png" alt="tiztrain_0-1737882368684.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have been trying to look at what is the difference with the web maps that work fine and what is the difference with the ones that does but can't figure it out. Does anyone have any advice here?&lt;/P&gt;</description>
      <pubDate>Sun, 26 Jan 2025 10:14:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/validationerror-assigning-a-web-map-to-a-variable/m-p/1578957#M11091</guid>
      <dc:creator>tiztrain</dc:creator>
      <dc:date>2025-01-26T10:14:03Z</dc:date>
    </item>
  </channel>
</rss>

