All,
I am exploring some scripting of the ArcGIS API for Python in the hope I can automate some future scenario. I have an administrator role on ArcGIS Online.
All I am trying to do is create a user that is a viewer as we have some unused viewer licenses to test with. My code is simply this, where xxx,yyy are my username and password.
from arcgis.gis import GIS
gis = GIS("https://geodatainstitute.maps.arcgis.com","xxx","yyy")
print(gis.users.counts('user_type'))
print("create a new user")
newuser = gis.users.create(username='testuserxxx', password='q1w2e3r4t5y6,.<>', firstname ='Firstxxx', lastname = 'Secondsxxx', email = 'test@test.com' , role='org_user', level=1, provider = 'arcgis')
if newuser is None:
print("FAILED!")
It always returns this:
create a new user
Unable to create testuserxxx
Unable to create testuserxxx
FAILED!
What am I doing wrong? I have followed the example as shown here. I have also tried connecting to https://www.arcgis.com but I still get the same error.
Is there some setting on AGOL that needs turning on/off, have I set up the role/level correctly? If one looks at the UserManager class on the API help file it confusing indicates that user_type is a required parameter but that seems not the case?
Any help or advice would be much appreciated.
Duncan