0

According to the API docs for User object there is a 'report' function. https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.User

I have an Administrator user role.

When I attempt to get a report for a user as shown below...

from arcgis.gis import GIS
import datetime as _dt

## connect to portal
agol = GIS("home")

## logged in user - returns a User object
user = agol.users.me

## https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.User
seven_days_ago = _dt.datetime.now(_dt.timezone.utc) - _dt.timedelta(days=7)
item = user.report("content", seven_days_ago, duration="weekly")

print(item)

I get the following error...

Traceback (most recent call last):
  File "C:\ArcGISPro\envs\arcgispro-py3-nbi\lib\site-packages\arcgis\gis\__init__.py", line 7272, in __getattr__
    return dict.__getitem__(self, name)
KeyError: 'report'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<module2>", line 12, in <module>
  File "C:\ArcGISPro\envs\arcgispro-py3-nbi\lib\site-packages\arcgis\gis\__init__.py", line 7274, in __getattr__
    raise AttributeError("'%s' object has no attribute '%s'" % (type(self).__name__, name))
AttributeError: 'User' object has no attribute 'report'

Has anyone successfully ran a user report using this method?

2
  • What sort of AGOL account do you have? Creating a report is generally an administrative function. You may not have the required access for report
    – KHibma
    Jul 4, 2022 at 19:52
  • Hi @KHibma I am an Administrator, ill edit the question to include that detail. Thanks Jul 5, 2022 at 8:09

1 Answer 1

1

I found that the report function was added at 2.0.1. My arcgis package version was 1.9.1. Upgrading the version enabled the report function for a User object.

For added context, my ArcGIS Pro is version 2.8. I have a cloned python environment that I can update using the Python Package Manager, but there was no arcgis package update available here. I used the command prompt with...

pip install arcgis --upgrade

... this upgraded the arcgis package to 2.0.1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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