I'm trying to update the privileges for one of my API keys using Python but I'm getting this stack trace and error message:
Traceback (most recent call last):
File "upload_shapefile_to_arc_as_feature.py", line 27, in <module>
api_key.update(http_referers=[], privileges=api_key_privileges)
File "/home/account_name/.local/lib/python3.6/site-packages/arcgis/gis/_impl/_apikeys.py", line 161, in update
return self._gis._con.post(url, params)
File "/home/account_name/.local/lib/python3.6/site-packages/arcgis/gis/_impl/_con/_connection.py", line 1079, in post
force_bytes=kwargs.pop("force_bytes", False),
File "/home/account_name/.local/lib/python3.6/site-packages/arcgis/gis/_impl/_con/_connection.py", line 625, in _handle_response
self._handle_json_error(data["error"], errorcode)
File "/home/account_name/.local/lib/python3.6/site-packages/arcgis/gis/_impl/_con/_connection.py", line 648, in _handle_json_error
raise Exception(errormessage)Exception: Unable to update app.
No update params specified
(Error Code: 500)
Here's some code to recreate:
from arcgis.gis import GIS
USERNAME = ""
PASSWORD = ""
API_KEY = ""
ITEM_ID_TO_GIVE_PRIVILEGE_FOR = ""
PRIVILEGE_TO_ADD = f'portal:app:access:item:{ITEM_ID_TO_GIVE_PRIVILEGE_FOR}'
gis = GIS(username=USERNAME , password=PASSWORD )
api_key = gis.api_keys.get(API_KEY )
api_key_privileges = api_key.properties.privileges
api_key_privileges.concat(PRIVILEGE_TO_ADD)
api_key.update(privileges=api_key_privileges)
The documentation link for the method I'm trying to use is here.
Any help would be appreciated!
Solved! Go to Solution.
The issue was that there was a typo in the arcgis package source code. It's in my Python39/Lib/site-packages/arcgis/gis/_impl/_apikeys.py file, at line 159. It used to be:
params["priveleges"] = privileges
and changing it to
params["privileges"] = privileges
makes it work.
The issue was that there was a typo in the arcgis package source code. It's in my Python39/Lib/site-packages/arcgis/gis/_impl/_apikeys.py file, at line 159. It used to be:
params["priveleges"] = privileges
and changing it to
params["privileges"] = privileges
makes it work.