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?
Solved! Go to Solution.
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>')
Just found another page with some info on this, I will look into it tomorrow.
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_admin, org_publisher, or org_user and see if that works.
Thanks! I tried this but still the same error though...
Also had a look at this other page, but no luck there either.
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
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.
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>')