I'm trying to automate some workflow that happens weekly. Got everything working except for removing the old and uploading the new data at the end. When done manually in ArcGIS Pro this is done using the Delete Features tool, then the Append tool. I put a model together to chain the two, I can run the model in Pro using the Python window and it works fine, but when I transfer the code to my script and run it stand alone it fails with a "ERROR 000732: Target Dataset: Dataset LayerName does not exist or is not supported" - the layer is hosted on our enterprise portal, so I thought maybe I needed to use
from arcgis.gis import GIS
gis = GIS("http://my.portal.address/", "username", "password")
LayerName = gis.content.get('f6f63262826e40adbc34e8d01ff9b3aa')
But this also fails with a
"""
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 4241, in DeleteFeatures
raise e
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 4238, in DeleteFeatures
retval = convertArcObjectToPythonObject(gp.DeleteFeatures_management(*gp_fixargs((in_features,), True)))
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
RuntimeError: Object: Error in executing tool
"""
I've tried entering everything into a Jupyter Notebook and viewing the file after assigning the portal path and it is displaying as expected, but I can't go any farther without errors. If I use a local path and file everything works fine, and I've tried a few different layers from our portal and they all produce the same error. Hoping for some help, thank you.