OneDrive报表API:period参数失效但date参数正常问题
Troubleshooting Empty Response for
getOneDriveUsageAccountDetail with period Parameter I've run into a similar issue with the Microsoft Graph Beta API before, let's break down what's happening and how to address it:
Problem Overview
- When calling the API with the
periodparameter (D30 for last 30 days):
The response returns an empty array:GET https://graph.microsoft.com/beta/reports/getOneDriveUsageAccountDetail(period='D30')?$format=application%2fjson{ "@odata.context": "https://graph.microsoft.com/beta/$metadata#Collection(oneDriveUsageAccountDetail)", "value": [] } - However, using the
dateparameter to specify a single day (e.g., 2020-10-05):
Returns valid data including theGET https://graph.microsoft.com/beta/reports/getOneDriveUsageAccountDetail(date=2020-10-05)?$format=application/json@odata.nextLinkand populatedvaluearray as expected.
Possible Causes
- Report Data Latency: Period-based aggregation reports (like D30) often have longer generation and sync times compared to single-date reports. It's possible the 30-day aggregated data hasn't been processed and made available in the Graph system yet.
- Permission or Tenant-Specific Restrictions: Even with the required
Reports.Read.Allpermission, some tenant configurations might restrict access to period-based usage reports, while allowing single-date data retrieval. - Beta API Limitations: Since this is a Beta endpoint, the
periodparameter implementation might be incomplete or have bugs that affect certain tenants (e.g., commercial vs. education tenants).
Recommended Fixes
- Wait for Data Sync: Give the system 24-48 hours to generate and sync the 30-day aggregated report, then retry the request.
- Double-Check Permissions: Confirm your application or user account has been granted the
Reports.Read.Alldelegated or application permission, and that there are no tenant-level policies blocking access to period-based reports. - Workaround with
dateParameter: If theperiodparameter remains unresponsive, iterate over each date in the 30-day window using thedateparameter, then aggregate the results locally. This ensures you get reliable data even if the period endpoint is broken. - Report the Bug: If you've ruled out latency and permission issues, submit feedback to Microsoft via their Graph API feedback channel—Beta endpoints rely on user input to fix such inconsistencies.
内容的提问来源于stack exchange,提问作者lijevosmetalo
相关产品推荐
相关产品推荐

