Good Morning,
I have been pulling some item usage data from AGOL using the Python API item.usage().
Seems to be working fine for a few of the queries, and not for others.
My python:
<SPAN class="keyword token">from</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>gis <SPAN class="keyword token">import</SPAN> GIS<SPAN class="punctuation token">,</SPAN>Item
gis <SPAN class="operator token">=</SPAN> GIS<SPAN class="punctuation token">(</SPAN><SPAN class="string token"><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F" target="_blank">https://</A><SPAN><organiztion>.maps.arcgis.com"</SPAN></SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"<username>"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"<password>"</SPAN><SPAN class="punctuation token">)</SPAN>
item <SPAN class="operator token">=</SPAN> Item<SPAN class="punctuation token">(</SPAN>gis<SPAN class="punctuation token">,</SPAN><SPAN class="string token">"<itemid>"</SPAN><SPAN class="punctuation token">)</SPAN>
chartdata <SPAN class="operator token">=</SPAN> item<SPAN class="punctuation token">.</SPAN>usage<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"<daterange>"</SPAN><SPAN class="punctuation token">,</SPAN>as_df<SPAN class="operator token">=</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>chartdata<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
The chart below shows which ones work for me.

If I run the 6M range, it returns:
Error generating usage report<SPAN class="punctuation token">.</SPAN>
None
Error generating usage report<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
If I run the 1Y range, it returns:
Traceback <SPAN class="punctuation token">(</SPAN>most recent call last<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
File <SPAN class="string token">"<filepath>.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">12</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> <SPAN class="operator token"><</SPAN>module<SPAN class="operator token">></SPAN>
chartdata <SPAN class="operator token">=</SPAN> item<SPAN class="punctuation token">.</SPAN>usage<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"1Y"</SPAN><SPAN class="punctuation token">,</SPAN>as_df<SPAN class="operator token">=</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN>
File <SPAN class="string token">"<windowsuserfolder>\AppData\Local\ESRI\conda\envs\new-environment\lib\site-packages\arcgis\gis\__init__.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">6371</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> usage
<SPAN class="keyword token">raise</SPAN> ValueError<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Invalid date range."</SPAN><SPAN class="punctuation token">)</SPAN>
ValueError<SPAN class="punctuation token">:</SPAN> Invalid date range<SPAN class="punctuation token">.</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
It doesn't matter whether you return the Pandas DataFrame or the python dictionary for the result, same errors get generated.
Am I missing something somewhere?
It would be really nice to get the longer date ranges for my automated reporting I'm working on.
Thanks for any help on this!!
Cameron