Create User for AGO 'Unable to Create <username>' error.

456
2
05-13-2021 03:20 PM
JPGarCar
New Contributor

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!

0 Kudos
2 Replies
jcarlson
MVP Notable Contributor

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.

- Josh Carlson
Kendall County GIS
Shaw007
New Contributor

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.