Select to view content in your preferred language

KeyError while overwriting feature layer

01-17-2019 08:04 AM
New Contributor III

I receive an updated csv file on a weekly basis. I am trying to upload/overwrite the existing csv file in AGOL and then use that to update/overwrite the corresponding feature layer. However, I am receiving a KeyError on the serviceItemId when I attempt to overwrite the feature layer. At a loss at this point so any help is greatly appreciated.


hiea_csv_item = gis.content.get(hiea_csv_id) # csv item id

hiea_item = gis.content.get(hiea_lyr_id) # feature layer id
#update csv using local file
hiea_csv_item.update({}, hiea_csv_file)
# call the overwrite() method to update feature layer & service
from arcgis.features import FeatureLayerCollection
hiea_feature_collection = FeatureLayerCollection.fromitem(hiea_item)
# 'HIEA/hiea_sample.csv' is the updated csv file in AGOL
hiea_feature_collection.manager.overwrite('HIEA/hiea_sample.csv') - fails

KeyError Traceback (most recent call last)
~\AppData\Local\Continuum\miniconda3\lib\site-packages\arcgis\gis\ in _check_publish_status(self, ret, folder)
7059 try:
-> 7060 serviceitem_id = ret[0]['serviceItemId']
7061 except KeyError as ke:

KeyError: 'serviceItemId'

During handling of the above exception, another exception occurred:

KeyError Traceback (most recent call last)
<ipython-input-11-5acc4e5f313c> in <module>()
1 #hiea_feature_collection.manager.overwrite('HIEA/hiea_sample.csv')
----> 2 hiea_feature_collection.manager.overwrite(hiea_csv_file)

~\AppData\Local\Continuum\miniconda3\lib\site-packages\arcgis\features\ in overwrite(self, data_file)
1167 #region Perform overwriting
1168 if related_data_item.update(item_properties=params, data=data_file):
-> 1169 published_item = related_data_item.publish(publish_parameters, overwrite=True)
1170 if published_item is not None:
1171 return {'success': True}

~\AppData\Local\Continuum\miniconda3\lib\site-packages\arcgis\gis\ in publish(self, publish_parameters, address_fields, output_type, overwrite, file_type, build_initial_cache)
6850 return Item(self._gis, ret[0]['serviceItemId'])
6851 else:
-> 6852 serviceitem_id = self._check_publish_status(ret, folder)
6853 return Item(self._gis, serviceitem_id)

~\AppData\Local\Continuum\miniconda3\lib\site-packages\arcgis\gis\ in _check_publish_status(self, ret, folder)
7060 serviceitem_id = ret[0]['serviceItemId']
7061 except KeyError as ke:
-> 7062 raise RuntimeError(ret[0]['error']['message'])
7064 if 'jobId' in ret[0]:

KeyError: 'error'

0 Kudos
0 Replies