User Delete - not licensed by user error

326
3
Jump to solution
05-07-2021 03:29 PM
AdamMesser1
New Contributor III

Our code for deleting inactive users on AGOL is failing on the user.delete() command after upgrade to Pro 2.7.0 using the python api 1.8.4. The final return is "Exception: not licensed by user (Error Code: 400)" with full return in attached file. These users do not have content or own groups or have any special licensing. To verify, a new test user with no content, etc. was created and exhibited the same issue. Upgraded to Pro 2.7.3 and api 1.8.5 did not solve the issue. Going back to the base python 3.7.9 install from the ve also did not change the error. As it seems related to entitlements, I added a license to the user to see if the error changed, it didn't. The user can be deleted manually via AGOL, and a different machine running Pro 2.3.2 and I believe api 1.6.2, can run this command without error. None of our other python api commands seem to be failing. Ideas on what I'm missing?

Tags (2)
1 Solution

Accepted Solutions
DanPatterson
MVP Honored Contributor

File an "Issue" on the arcgis-api site

Issues · Esri/arcgis-python-api (github.com)

 


... sort of retired...

View solution in original post

3 Replies
DanPatterson
MVP Honored Contributor

File an "Issue" on the arcgis-api site

Issues · Esri/arcgis-python-api (github.com)

 


... sort of retired...

View solution in original post

AdamMesser1
New Contributor III

Will do. Thanks @DanPatterson 

0 Kudos
ChristopherSchreiber
Occasional Contributor II

Thanks for posting about this! I ran into the same issue! 

As a workaround, you could hit the REST API directly. You can do this by using the 'Requests' library and Esri's REST API.

 

 

 

 

token = gis._con.token
url = '{0}/sharing/rest/community/users/{1}/delete?f=json&token{2}'.format(gis.url, username, token)
deleteAgolUser = requests.post(url)
print("Delete User Results for user {0}: {1}".format(username, deleteAgolUser.text)

 

 

 

 

"token" in the above snippet, gets the token that is generated when you authenticate using GIS. See this post for more details. 

The 'print' statement is just something that I use, feel free to ignore it!

 

I hope this helps someone! 

 

Chris