I have a file geodatabase with 100 layers in it. I want each layer to be its own item in AGOL and I'm trying to write a script that will automatically publish them to AGOL. (The hope is I can re-use this later)
I've seen a couple of different methods for publishing layers to AGOL. The one I'm using now uses something like the following code:
# feature class has been exported to its own GDB
# new gdb has been compressed to a .zip file
item = gis.content.add(path to zipped GDB)
published_item = item.publish(overwrite=True)
This is resulting in a "Job failed" error and I don't understand why. I've seen that it's possible to use a service definition, but I only want the hosted feature and I don't care about having a map service. Is the service definition method the only way to actually accomplish what I want to do?
Here is how I would approach this if I had access to ArcGIS Pro and ArcPy and avoiding the use of the ArcGIS API for Python.
This will go through all feature classes in the gdb and publish each one individually to ArcGIS Online (or Portal) as Hosted Feature Services. You will need to define the name of the Feature Service on each iteration which can simply be the name of the feature class itself.
You can use the same workflow with some minor tweaks to overwrite the feature services too should the need/want arise