Hey all,
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 '
ValidationError: 108 validation errors for Webmap
Out of the 52 web maps, only a small portion don't have the error.
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")
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:
---------------------------------------------------------------------------
ValidationError Traceback (most recent call last)
Cell In[6], line 6
4 print (wm_item)
5 # access the Map object
----> 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
--> 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
--> 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
--> 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
The successful processed web maps output the following:
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?