Hi There,
I have set up some code to be able to add a single user to multiple groups in arcgis online. This works fine when using the add_users() or the invite_users() methods for an internal user but when I try to do it for an external user with the invite_users() method it doesn't work.
The method returns the value 'True' but it doesn't actually do anything. I have sent invitations to the same user using the button on the group page so the user and group are setup correctly.
Is it possible to add external users to groups using python, do I need to specify that these users are external somewhere? Any help gratefully received!
Hey Deirdre,
Can we just confirm that the group has been configured for external users to be able to be added? The documentation here shows the setting that needs to be enabled for this.
Hi David,
Yes the group is set up to allow users from any organization to join and as a test I invited the external test user to the group using the button on the group details page and they received the invitation ok so in theory it should work.
Dee
This is the code I am using:
@David_McRitchie I'm just wondering if you have any further advice on this issue? If there is anything I need to add to the above code to get it to work that you can think of please let me know, it would be greatly appreciated!
Thanks and regards,
Dee
@David_McRitchie Was there a resolution for this question? I have an almost identical problem and script, and have verified that both the groups and user settings are configured correctly, because I can add them manually one at a time. Is the API capable of searching external orgs for either an external username or the external user's associated email?
Apologies on the delay, I'm just coming back to this after a busy period.
I tried testing this and think there is a slight formatting issue within the code.
At the end we are passing the username into the invite_users method directly as a string.
for group in AddToGroups:
result = group.invite_users(userN)
print(result)
Instead we need to pass this through as a list based on the sample in the documentation.
for group in AddToGroups:
result = group.invite_users([userN])
print(result)
Hopefully that fixes things, please let me know if not and we can look further.
David
Hi David! Thanks for your reply. My understanding is that in order to add external users, emails would be required and not usernames(?). The problem is that when I try it nothing happens - invites do not get sent.
I've been able to use my script to add internal users from a list just fine. I had more complex sections to check and see if the list contained members already present, check for valid email address formats, separate sections for adding users and for inviting users, and it does not work on external users at all. Which is why I was asking if the API is capable of sending invites to external users. As an aside, it isn't possible to query a group for pending invites, so there isn't any way to validate it other than asking my external users directly, and their patience for this effort is not limitless.
Dummy values here:
#get groups
groupids = ['groupid1', 'groupid2'
]
#list of members to add
users = ['user1@organization.com', 'user2@organization.com'
]
#add everyone
for group in groupids:
grp = gis.groups.get(group)
try:
result = grp.invite_users(users)
print (result)
except Exception as e:
print ('\tNo access to '+ grp.title)
print (e)