Using ArcGIS Notebooks in ArcGIS Online (AGOL), I've been able to create users as an admin with the following code from this documentation:
from arcgis.gis import GIS
gis = GIS("home")
gis.users.create(username='TESTTWO@newwestcity.ca',
password=None,
firstname='TEST',
lastname='TWO',
email='gis@newwestcity.ca',
user_type='Creator',
role='org_user',
groups=None)
However, when I try this code using PythonCreator, according to this example:
from arcgis.gis import GIS
def FeatureCreator(feature):
gis = GIS(profile="gis_services1")
gis.users.create(username='TESTTHREE@newwestcity.ca',
password=None,
firstname='TEST',
lastname='THREE',
email='gis@newwestcity.ca',
description='TEST USER',
user_type='Creator',
level=2,
role='org_user',
provider='arcgis',
groups=None
)
I get the following error after running the transformer:
Python version 3.6 loaded successfully
Adding folder `H:\MapLibrary_ArcGISOnline\_Admin\InformationTechnologyServices\addusers_pythonapi\FME\' to the python path
Reading...
Emptying factory pipeline
Router and Unexpected Input Remover (RoutingFactory): Tested 0 input feature(s), wrote 0 output feature(s): 0 matched merge filters, 0 were routed to output, 0 could not be routed.
Unexpected Input Remover Nuker (TeeFactory): Cloned 0 input feature(s) into 0 output feature(s)
CSV_CSV2_1 Splitter (TeeFactory): Cloned 0 input feature(s) into 0 output feature(s)
Python Exception <KeyError>: 'groups'
Error encountered while calling function `FeatureCreator'
PythonCreator (PythonFactory): PythonFactory failed to process feature
PythonCreator (PythonFactory): A fatal error has occurred. Check the logfile above for details
PythonCreator_Creator (CreationFactory): A fatal error has occurred. Check the logfile above for details
A fatal error has occurred. Check the logfile above for details
Translation FAILED with 6 error(s) and 0 warning(s) (0 feature(s) output)
FME Session Duration: 21.3 seconds. (CPU: 5.4s user, 12.1s system)
END - ProcessID: 10044, peak process memory usage: 306572 kB, current process memory usage: 290600 kB
A fatal error has occurred. Check the logfile above for details
Program Terminating
Translation FAILED.
I've looked into several community posts without success:
- https://community.esri.com/t5/arcgis-api-for-python-questions/creating-new-user-via-arcgis-api-for-python/td-p/723101/page/2
- https://community.esri.com/t5/admin-tools-questions/using-arcgis-api-for-python-how-do-i-add-all-users/m-p/866201
- https://community.esri.com/t5/arcgis-api-for-python-questions/unable-to-create-a-new-user-via-arcgis-api/td-p/811806
From the logs, it looks like the issue is with groups argument. Looking at this documentation, the description for Groups is 'Optional List. An array of Group objects to provide access to for a given user. (10.7+)'.
I'm using FME Desktop 2021.1 with Esri ArcGIS Python 3.6+ as the Python Interpreter.
That's all the info I have for now, thank you in advance.