update_role not working?

405
2
05-15-2019 07:36 AM
FayDearing
New Contributor

Hello,

So recently I wrote a script that would change a user's custom role. Initially it was working, but recently it's broken and I'm not sure how to fix it. The error message I'm getting is a RuntimeError (400) "Unable to update user role. 'user' parameter required or invalid." Has anyone else been having this issue? A rough breakdown of the script is below.

from arcgis.gis import GIS

gis = GIS("https://www.arcgis.com","Admin Username,"Admin Password")

Username = "A user from my organization"

UserRole = "Custom user role id for role I want to change my user to"

testUser = gis.users.get(Username)

testUser.update_role(role = UserRole)

print("Complete!")

According to my script the break always happens at the update_role line and it's always that same RuntimeError. I've checked the documentation for the command and I don't see what I'm doing wrong, especially since it used to work just fine. The Admin account does have permissions to change account roles as well. You can still successfully change roles manually, just not through python.

Any suggestions? Thanks much!

Tags (1)
2 Replies
JohnHettinger
New Contributor

I have the same problem.  Every other function I've used works fine, but update_role fails with the same "'user' parameter required or invalid" error.  I am using a slightly older arcgis Python library, 1.5.1, but that is what my company is using with its official ArcGIS Pro install so I'm pretty much stuck with it for now.  I'm using the Python api to work with my company's ArcGIS Online domain: <domain>.maps.arcgis.com

0 Kudos
ThorstenHohenstrater
New Contributor III

This seems to work (need to use the RoleID of the Role):

user = gis.users.get('Username')

user.update_role('RoleID')

Thorsten Hohenstrater
0 Kudos