AnsweredAssumed Answered

How to query and set user first and last names in Portal

Question asked by BeaudetC1_Weyerhaeuser on May 30, 2018
Latest reply on Aug 30, 2018 by hiker4k

I'm new to the ArcGIS Python API and Jupyter Notebooks so I may just be doing something wrong, but I'd like to update users in AGOL with their last names (since auto-register is not adding last names) but even trying to query for first and last names gives the error:

AttributeError: 'User' object has no attribute 'firstName'

This is the code in my notebook:


import arcgis
from arcgis.gis import GIS
from IPython.display import display
import getpass
password = getpass.getpass("Enter Password: ")
gis = GIS("", "Admin User", password)

user_accounts ='',max_users=700)
for a in accounts:
   print (a.firstName)


I've tried a bunch of variations on 'firstName', e.g. 'firstname', 'first_name', 'FirstName', 'firstname', etc. but always get the same result.  According to sample code on the Python API Samples page, 'firstName' should work. Also according to the API reference, the User object should have a 'userdict' object...

classarcgis.gis.User(gis, username, userdict=None)


...but I can't seem to get that either.  But maybe I'm reading that wrong?


I can resolve and print the username fine, i.e. "print (a.username)", so I know I have valid User objects.  


I've found online that it isn't until v1.4.1 that we are able to update users with first and last name.  I'm not sure what version I'm running locally and also not sure how to find it -- is there a command I can run in Notebook to give me the Python API version number?


I tried running this same code in the online Jupyter Notebook on the Esri Python API 'try it live' site,which I was hoping is the latest version, but I'm getting the same error there.


Any thoughts?