I am trying to create an empty Hosted Feature service from my app using the ArcGIS REST API. I want that service to have multiple layers, and the fields would be dynamically created at creation type.
One would think that the createService API call (https://developers.arcgis.com/rest/users-groups-and-items/create-service/) would be the right thing to look at, right? Unfortunately, it looks like ESRI wants only the admins to do this. The documentation says: "This endpoint is only accessible to the content owner and members who are assigned the default administrator role. All other members will receive a permissions error when attempting to access this endpoint."
So then I looked into how ArcGIS Online does it and looks like they use a combination of /addItem (https://developers.arcgis.com/rest/users-groups-and-items/add-item/) and /publish (https://developers.arcgis.com/rest/users-groups-and-items/publish-item/) to achieve this.
To achieve what I need, I would have to first create a file GDB with my required layers, upload that, and then publish it. And this would mean that an uploaded file geodatabase is left as a file item, which just feels icky.
Is there a better way to do what I need to do?
createServiceand then carry on withaddToDefinition,updateandupdateItemsas needed. (Open browser dev tools and follow the flow while logged in as a publisher using Content > New Item > Feature Layer)