Select to view content in your preferred language

Create ArcGIS Online user

1033
6
Jump to solution
10-25-2023 07:53 AM
jorisfrenkel
Frequent Contributor

I am trying to create a user with Python in ArcGIS Online. Tried this in Notebook in ArcGIS Online, in Idle for Pro (3.1.1), in a Notebook in Pro and in the command line in Pro. Every time I receive the same error message.

The code is:

from arcgis.gis import GIS
gis = GIS("home")

newuser = gis.users.create("testuserxyz_sbbabc1","1234567890QWERTYuio","Dumbo","Dumbo2","test@test.com")

The error message:

TypeError Traceback (most recent call last)
In [3]:
Line 4: newuser = gis.users.create("testuserxyz_sbbabc1","1234567890QWERTYuio","Dumbo","Dumbo2","test@test.com")

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\gis\__init__.py, in create:
Line 3283: return self._create64plus(**params)

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\gis\__init__.py, in _create64plus:
Line 3638: "groups": ",".join([g for g in groups if g]),

TypeError: sequence item 0: expected str instance, Group found

 

Any ideas?

 

 

0 Kudos
1 Solution

Accepted Solutions
jorisfrenkel
Frequent Contributor

ESRI Netherlands support helped me out with this. It has been logged as a bug. 

This happens when there's a default group that is assigned to all new members in ArcGIS Online. The workaround is adding the groups parameter to the request, with the ID of the group, like this:

gis.users.create(username='username',
                 password='password',
                 firstname = 'Peter',
                 lastname='Parker',
                 email='PParker@test.com',
                 description='Test user',
                 role='sadc65er16c1e5f',
                 user_type='Creator',
                 groups='<group-id>')

 

 

 

View solution in original post

0 Kudos
6 Replies
jorisfrenkel
Frequent Contributor

Just found another page with some info on this, I will look into it tomorrow.

0 Kudos
EarlMedina
Esri Regular Contributor

The error is unexpected for what I think the cause is - I believe you are missing the required "role" parameter. Add another argument at the end equal to org_adminorg_publisher, or org_user and see if that works. 

jorisfrenkel
Frequent Contributor

Thanks! I tried this but still the same error though... 

Also had a look at this other page, but no luck there either.

0 Kudos
David_McRitchie
Esri Contributor

Hey Joris the following support article might be a good sample to follow for this. I believe you need to specify a user type and user role

 

gis.users.create(username='username',
                 password='password',
                 firstname = 'Peter',
                 lastname='Parker',
                 email='PParker@test.com',
                 description='Test user',
                 role='sadc65er16c1e5f',
                 user_type='Creator')

 

Please let me know if you have any further issues with this,

David

Esri UK -Technical Support Analyst
jorisfrenkel
Frequent Contributor

Thanks for your suggestion.

Thanks to our local ESRI support, it seems likely that the issue is caused by a default group that is specified for new members in our ArcGIS Online organisation. I still need to confirm this, I will post an update.

0 Kudos
jorisfrenkel
Frequent Contributor

ESRI Netherlands support helped me out with this. It has been logged as a bug. 

This happens when there's a default group that is assigned to all new members in ArcGIS Online. The workaround is adding the groups parameter to the request, with the ID of the group, like this:

gis.users.create(username='username',
                 password='password',
                 firstname = 'Peter',
                 lastname='Parker',
                 email='PParker@test.com',
                 description='Test user',
                 role='sadc65er16c1e5f',
                 user_type='Creator',
                 groups='<group-id>')

 

 

 

0 Kudos