I am using the Python package to create a script that should create AGO users.
When testing the package, I create the GIS object using my account details (I have admin role) and then create the new user, but an "Unable to create <username>" error is thrown.
When investigating the issue, it seems when the package sends the post request, the username is returned in the "notInvited" list and thus the user creation fails. I tried using a real email but it still fails.
I have searched the web for a while now and have found no solutions to this problem.
Code:
# school is replaced by my school name, xxx and yyy are my username and password
gis = GIS(url='https://school.maps.arcgis.com', username='xxx', password='yyy')
newuser = gis.users.create(
username='pythontest',
password='10@1232.adbsd.ADSF',
firstname='python',
lastname='test',
email='pythonTest@gmail.com',
)
Thank you in advance!
Looking at the API docs, it would appear that the user_type is a required string. Try your same code but with "user_type='Viewer'"added to the parameters.
I was facing the same issue mentioned above and was able to resolve it by adding the user_type and the role syntax. Now how to know which user_type and role to add, refer to the following documentation (Create User—ArcGIS REST APIs | ArcGIS Developers). Check sections "role" and "userLicenseTypeId".
Example = I am creating a new user with role (Viewer) and user type (Viewer). As per the above cited documentation I will use role as "iAAAAAAAAAAAAAAA" and user_type as "viewerUT". Hope this helps.