Select to view content in your preferred language

addFeatures with token "User does not have the privilege to perform this operation."

551
3
02-21-2023 10:59 AM
JamesGough
Occasional Contributor

I am attempting to add features to a feature service as part of an automated script using the REST API. However when I POST to the /addFeatures resource I get Error 500 - "User does not have the privilege to perform this operation."

I created an application on our Portal site where the hosted feature service is published. The feature service is shared only with a group.

I am using a token that i get from making a POST request to /portal/sharing/rest/oauth2/token on our ArcGIS Enterprise site (10.8.1) with the following body:

client_id=<app id>
grant_type=client_credentials
client_secret=<app secret>

This successfully returns an access token. I can use the token to query the feature service, but not to addFeatures. It seems like the application has read permissions to the feature service but not write.

Is there some way to grant the application credentials access to the feature service for editing?

 

 

Edit: By the way, editing is enabled and I can manually use the /addFeatures REST page to add features after signing in. Making a request with the token fails though.

0 Kudos
3 Replies
sxw_eaglegis
Esri Contributor

Hi JamesGough - I don't believe this is possible - https://developers.arcgis.com/documentation/mapping-apis-and-services/security/application-credentia...

Is this a python automated script? You may be better off using the ArcGIS python API to do the edits if you are, which would take care of the authentication process for you.

0 Kudos
JamesGough
Occasional Contributor

It is a node.js application. That is too bad, it would be ideal if we could configure access permissions for the app, such as read-only, create/update-only, create/update and delete.

0 Kudos
Yik-ChingTsui
New Contributor III

I had this problem too. Turns out you need an OAuth token and not the token from generateToken. OAuth allows editing features and isn't just read-only. The code I used is here: https://gist.github.com/YikChingTsui/ff6d7b6126db73a77e5845576250177d

0 Kudos