AnsweredAssumed Answered

Unable to create a new user via ArcGIS API

Question asked by Hornbydd Champion on Jan 14, 2020
Latest reply on Feb 21, 2020 by adrian.hughes_RSPB

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
# User name is case sensative as is password!
gis = GIS("https://geodatainstitute.maps.arcgis.com","xxx","yyy") # https://www.arcgis.com
print(gis.users.counts('user_type')) # This line runs OK
print("create a new user")
newuser = gis.users.create(username='testuserddh', password='q1w2e3r4t5y6,.<>', firstname ='Firstddh', lastname = 'Secondsddh', 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 testuserddh
Unable to create testuserddh
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

Outcomes