Closed l84tahoe closed 3 years ago
@l84tahoe Please provide reproducible code and arcgis api version.
Thank you
@achapkowski API 1.6.1
from arcgis.gis import GIS from arcgis.gis import admin gis = GIS("https://portal.com/portal","userName") serverList = gis.admin.servers.list() server1 = serverList[0] usageReports = server1.usage.list() Print(usageReports)
Also we do use IWA as our authentication.
@l84tahoe I'll take a look. Thanks
@achapkowski Here is the console output:
TypeError Traceback (most recent call last)
what version of arcgis server?
10.6.1
Just came here to create the same issue. Below is the text from the ESRI support ticket I just created. I'm on API version 1.5.3 with a 10.6.1 server.
I am attempting to run my server reports through the ArcGIS Python API and I keep gettings the following error. Traceback (most recent call last): File "G:/Data/GISAutomation/Python/Py3.x/Dev - To Do/Dev-ManageServer.py", line 35, in
usage_reports = Traditional.usage.list() File "C:\Users*\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\server\admin_usagereports.py", line 70, in list url = self._url + "/%s" % six.moves.urllib.parse.quote(r['reportname']) File "C:\Users*\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\urllib\parse.py", line 789, in quote return quote_from_bytes(string, safe) File "C:\Users***\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\urllib\parse.py", line 814, in quote_from_bytes raise TypeError("quote_from_bytes() expected bytes") TypeError: quote_from_bytes() expected bytes This is from simply trying to run the below code. portal = api.GIS("https://gis.trpdmn.org/portal", "*", "****") traditional_url = 'https://gis.trpdmn.org/traditional/admin' Traditional = server.Server(traditional_url, portal) usage_reports = Traditional.usage.list() print(usage_reports)
@achapkowski & @l84tahoe,
I found a solution that worked for me. I went into my server admin's usage report area (server url/admin/usagereports) and found that there were a few reports that had really long # names (ex: 123098345098). I deleted those reports and my code is now working.
I remember that I was playing with a code example I saw on (managing-your-gis-servers) that generates a quick report.
data = server1.usage.quick_report(since="LAST_MONTH", metrics="RequestCount") data['report'].keys()
If I'm remembering correctly, then these reports I deleted may have been generated from this quick_report meaning that they are incompatible with usage.list(). Hope that works for you. Let me know if you need any more info from me.
Is this still an issue using the latest version of the ArcGIS API for Python?
@achapkowski I have changed organizations since creating this issue. With the newest API I no longer get the error I was experiencing before. But I am just getting a link to the usage report params. I guess I just need to append /data
to the end of the URL to get the data. There might be another built in method, but I haven't had to use the usage reports since my change. But will most likely come across this again once I have Enterprise set up fully at my new org.
When trying to list usage reports using the Python API against a 10.6.1 federated hosting server I receive the error
quote_from_bytes() expected bytes
from\conda\envs\gis\lib\urllib\parse.py
I also receive this error when trying to create a quick report.