Cannot add a user to a group

355
3
10-18-2017 09:53 AM
AitorCalero_García
Esri Contributor

Hello, I'm trying to add a user to group without invitation and it does not work. Here is the code I'm using:

newuser = gis.users.create(username = "name.surname",
                            password = None,
                            firstname = "Name",
                            lastname = "Surname",
                            email = "name.surname@email.com",
                            role="org_publisher")
group.add_users(newuser)

And I get this:

{'notAdded': ['lastLogin',
  'privileges',
  'access',
  'role',
 ... ROWS DELETED 
  'username']}

If I try instead to use group.add_users("name.surname") I get this:

{'notAdded': ['a', 'r', 's', 'e', 'u', 'M', 'n', '.']}

The "group" object is valid, btw. and I set its invitation policy to false using this: "is_invitation_only=False"

What I'm doing wrong? How can I add a user to group without invitation?

Thanks in advance!

Tags (3)
0 Kudos
3 Replies
AitorCalero_García
Esri Contributor

I've solved the issue modifying the add_users call using brackets:

group.add_users([newuser])

However, the API returns this:

{'notAdded': ['antonio.remirez.geogeeks']}

It says notAdded but when you look into the group members the user is there.

Thanks Antonio Remírez Remírez‌!

0 Kudos
JohnYaist1
Esri Contributor

Thanks, aitor.caleroesri-es-esridist‌ - the add_users method returns a dictionary with one key, 'notAdded', and a list of users that did not successfully get added to the group. We'll take a look at what that method returns to investigate how to clear up any confusion.

AitorCalero_García
Esri Contributor

Thank you John. Now I understand the response. However, it's somewhat confusing...