Select to view content in your preferred language

AGOL User object 'report' method/function errors

904
3
Jump to solution
07-04-2022 07:36 AM
Clubdebambos
Frequent Contributor

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

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?

~ learn.finaldraftmapping.com
Tags (4)
0 Kudos
1 Solution

Accepted Solutions
Clubdebambos
Frequent Contributor

Thank @FrédéricPRALLY 

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. 

~ learn.finaldraftmapping.com

View solution in original post

3 Replies
FrédéricPRALLY
Esri Contributor

Hi Clubdebambos,

From ArcGIS Pro Notebook I can run successfully a user report using your method.

 

Maybe check:

- ArcGIS Pro version 3.0

- Create a new python env,

- From Pro are you connected to your AGOL account.

 

Hope this help you,

Fred

0 Kudos
Clubdebambos
Frequent Contributor

Thank @FrédéricPRALLY 

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. 

~ learn.finaldraftmapping.com
FrédéricPRALLY
Esri Contributor

Hi @Clubdebambos ,

Perfect ! Thank for your update,

Have a good day,

Fred

0 Kudos