0

I am working on ArcGIS Notebooks

from arcgis.gis import GIS
from IPython.display import display
agol_gis = GIS("https://*********.maps.arcgis.com/home/")
agolSiteAdmin = agol_gis.users.get('siteadmin')
print(agolSiteAdmin.groups)

I am getting following error

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/opt/conda/lib/python3.6/site-packages/arcgis/gis/__init__.py in __getitem__(self, k)
   5714         try:
-> 5715             return dict.__getitem__(self, k)
   5716         except KeyError:

KeyError: 'groups'

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
<ipython-input-159-b0f847f656f3> in <module>
      1 # Print all groups
----> 2 print(agolSiteAdmin.groups)

/opt/conda/lib/python3.6/site-packages/arcgis/gis/__init__.py in groups(self)
   5883     def groups(self):
   5884         """Gets a list of Group objects the current user belongs to."""
-> 5885         return [Group(self._gis, group['id']) for group in self['groups']]
   5886     #----------------------------------------------------------------------
   5887     def update_license_type(self, user_type):

/opt/conda/lib/python3.6/site-packages/arcgis/gis/__init__.py in __getitem__(self, k)
   5717             if not self._hydrated and not k.startswith('_'):
   5718                 self._hydrate()
-> 5719             return dict.__getitem__(self, k)
   5720 
   5721     def __str__(self):

KeyError: 'groups'

I am using the following version

# packages in environment at /opt/conda:
#
# Name                    Version                   Build  Channel
ipython                   7.5.0            py36h39e3cac_0    defaults
ipython_genutils          0.2.0                    py36_0    defaults
1

users.get in the Python API for AGOL requires the actual username in Portal or AGOL of one of you account members. While using "siteadmin" returns a result this is not the actual administrator of your AGOL account unless they have the username of "siteadmin".

Provide a username for an account within your Portal or AGOL organization and provided that they belong to groups in AGOL you will be able to use print(agolSiteAdmin.groups) successfully.

Here is the documentation users.get

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.