I'm using the API to overwrite hosted feature layers and vector tiles using the technical support article below. If ArcGIS Pro isn't running, feature layers don't get overwritten but vector tiles do. I receive an error saying, "Error Creating and Republishing Service Definition file for <layer name>. ValueError('Unable to connect to portal.')". As soon as I open ArcGIS Pro and run the script, the feature layers do get overwritten. I don't even have to be connected to portal. Any ideas? This one has everyone stumped, including ESRI!
Yes, we do use Task Scheduler and reference "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe" and the script as the argument but the script still fails on the feature layers. Also, I'm not signed into any portal in ArcGIS Pro for the script to run without error.
Vector tiles are a bit trickier to "overwrite", and can be quite the headache to work with in that way.
In recent updates, you can now publish your feature service with a vector tile service "linked" to it.
Once published, all you need to do is tell the vector tile service to rebuild its cache, no need to overwrite.
And for scripting purposes, that button's python equivalent is right here.
Semi-related question: is "overwriting" really what you want to do here? Unless you're making changes to the schema and/or layer arrangement, you're probably better off using a truncate / append process.
Edit to add: For the portal issues, since you're using the ArcGIS Python API, why not use arcgis.GIS('url', 'user', 'password')?
Hi Josh! In contrast to the original post here, I have successfully overwritten my hosted feature service but having an error with my tile service. I'm not as familiar with vector tile services but the one I've published is a vector tile service/package. I published directly from ArcGIS Pro, perhaps before the new functionality. Is the recommended workflow to publish a feature service with a vector tile service linked to it? How would I update the vector tile service routinely, using a hosted layer in AGOL that is updated in real-time?
The error I am having is with the arcpy .publish function where it asks me to specify a file type, but then says my item is not supported. I'm not sure what the issue is.
Thanks for responding Josh but we are only having issues overwriting feature layers.
Ah, sorry! I sort of flip-flopped your post title in my mind when I read it.
So, why is it you're overwriting the feature layer, as opposed to a truncate/append process?