Greetings all,
I followed the workflow as shown on the follow page (https://developers.arcgis.com/python/sample-notebooks/overwriting-feature-layers/) and am receive a key error when attempting to publish my shapefile into a feature layer. My code used to work fine and started throwing an error after no changes were made. My code and error are found below
#Add the shapefile as an item (which publishes perfectly fine)
item_prop = {'title': '2021 NPU Applications', 'tags': 'GIS', 'type':'Shapefile'}
shapefile_item = gis.content.add(item_properties=item_prop, data=my_shapefile)
shapefile_item
#Publish the shapefile item into a feature layer (which throws an error)
Applications_item = shapefile_item.publish()
Applications_item
--------------------------------------------------------------------------- KeyError Traceback (most recent call last) <ipython-input-24-2d2a4fbd26be> in <module> 1 #Publish the shapefile item into a feature layer ----> 2 Applications_item = shapefile_item.publish() 3 Applications_item C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\__init__.py in publish(self, publish_parameters, address_fields, output_type, overwrite, file_type, build_initial_cache) 8860 elif not buildInitialCache and output_type is not None and output_type.lower() in ['sceneservice']: 8861 return Item(self._gis, ret[0]['serviceItemId']) -> 8862 elif not buildInitialCache and ret[0]['type'].lower() == 'image service': 8863 return Item(self._gis, ret[0]['serviceItemId']) 8864 else: KeyError: 'type'
Moving this to the api for python questions community
ArcGIS API for Python - GeoNet, The Esri Community
Thanks for that
Since my error was dealing with the default parameters being recognized correctly, I instead typed out the parameters which I found here (https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.Item.publish)
Hence I used the code:
#Publish the shapefile item into a feature layer
Applications_item = stapefile_item.publish(publish_parameters=None, address_fields=None, output_type=None, overwrite=False, file_type=None, build_initial_cache=False)
Applications_item
*I thought this was a solution but it did not
Hi @SharitaU ,
I've already provided two scripts in the link below for appending and overwriting a feature layer:
I hope that helps.
I am experiencing the same problem. Uploading the shapefile is OK but publishing it is not. I can publish it manually on ArcGIS Online. I don't think it's a issue with file overwriting as I tried to rename it every time. Have you solved this problem?