I am writing a script that will overwrite a feature layer on AGOL from a feature class I manage in a GDB - the issue I'm having is the .overwrite path
This is the script I have currently have is below. I successfully connect to AGOL and access the selected feature layer - but the script fails on line 21. The error is below.
import arcpy
from arcgis import GIS
from arcgis.features import FeatureLayerCollection
import os
# AGOL Details
username = 'myaccount'
password = 'password'
gis = GIS("https://www.arcgis.com", username, password)
# Item ID for feature to overwrite
itemid = '44ace4fd9e764c36bac2b9056679faee'
# Details for fc
GDB = r'H:\Projects\AGOL Overwrite Features\AGOL Overwrite Features.gdb'
newname = os.path.join(GDB, 'Test_Points_Overwrite')
# Overwrite feature layer
dataitem = gis.content.get(itemid)
flayercol = FeatureLayerCollection.fromitem(dataitem)
flayercol.manager.overwrite(newname)
Error:
File "H:\Projects\AGOL Overwrite Features\overwrite.py", line 50, in <module>
flayercol.manager.overwrite(newname)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\features\managers.py", line 2271, in overwrite
publish_parameters, overwrite=True
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\gis\__init__.py", line 12743, in publish
serviceitem_id = self._check_publish_status(ret, folder)
Instead of the variable 'newname' I've also tried fc = r'path to feature class in GDB' which got the same error.
Any help would be much appreciated 🙂