Select to view content in your preferred language

How to create an empty Hosted Feature service using the ArcGIS REST API using API key authentication?

58
0
Thursday
Labels (1)
devdattaTH
New Contributor

I am trying to create an empty Hosted Feature service from my python script using the ArcGIS REST API. I want that service to have multiple layers, and the schema would be dynamically created at creation type.

I thought of using API key authentication, as it would be an internal script, and would run without any human interaction.

I thought that the createService API call (https://developers.arcgis.com/rest/users-groups-and-items/create-service/) would be the right thing to look at. Confusingly, 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."

When I tried using this API via postman, I got the error message: ["User '<UserName>' does not have publishing privileges"].

The API key has been created by an account, which has a publisher role, and can create an empty feature service in the WebUI using the New Item >> Create a feature layer>> Define Your Own Layer flow.

For debugging purposes, I checked using oAuth Based authentication, and if I used the access token from there, I could successfully use the createService API call.

But since I need to run the Script in an Automated manner every week, I can't really use an OAuth Based authentication.

What's the right method to make the createService API call using API key authentication?

0 Kudos
0 Replies