Updating group member roles through Python API

462
1
02-18-2019 11:33 AM
JamesMacCarthy
New Contributor

Is there a way to add a user to a group as a group admin using the "add_users" function in the python API? I saw there is a way to do this with the role parameter in the "invite_users" function but not sure why there isn't the same parameter for "add_users." Would rather just invite the user instead of requiring them to accept an invitation...

Also tried looking for a way to update group member roles through the python API and can't seem to find anything to elevate a group member from user to admin. Is this possible?

Thanks for any help you can provide!

0 Kudos
1 Reply
VishApte
Esri Contributor

I have a same problem in 10.7.1. There is no Python API to elevate user's role in a group.

I am working on large script to migrate portal named users to SAML log-ins. ArcGIS API for Python does not seem to have every REST API covered. I ended up making REST calls in some places where Python API doesn't exist or returns error. Here is a code for updating users' role in a group to group admin.

grp_user_role_url = r"{}/sharing/rest/community/groups/{}/updateUsers".format(base_portal_url, group_obj.id)
params = {'admins': user_obj.username,
          'token': portal_token,
          'f': 'json'}
encoded_params = urlencode(params).encode()
request = Request(grp_user_role_url, encoded_params)
request.add_header('Referer', base_portal_url)
rest_upd_user = urlopen(request).read().decode()
json_response = json.loads(rest_upd_user)
0 Kudos