关于Microsoft Graph Recent API未返回LastAccessedDateTime的技术问询
Let's break down your questions one by one in a straightforward way:
1. Does the Microsoft Graph Recent API capture open events for read-only files?
Short answer: No, it doesn't.
The Recent API (/me/drive/recent) is built to track files you’ve actively interacted with—think actions like editing, uploading, sharing, or adding comments. Simply opening a read-only file to view it (without making changes or adding any other interactions) doesn’t count as an event that triggers the API to include the file in its results, nor does it update the lastAccessedDateTime field in the response. The API’s focus is on files you’ve "engaged with," not just passively viewed.
2. Alternative ways to get the lastAccessedDateTime property
Since the Recent API doesn’t return this field, here are reliable workarounds to retrieve it:
Fetch individual file details directly
Use the Drive Item endpoint to pull full details for a specific file, explicitly requesting thefileSystemInfoproperty with the$selectparameter:GET https://graph.microsoft.com/v1.0/me/drive/items/{file-id}?$select=fileSystemInfoA successful response will include the complete
fileSystemInfoobject:{ "fileSystemInfo": { "createdDateTime": "2018-05-14T10:15:21Z", "lastModifiedDateTime": "2018-05-14T10:15:00Z", "lastAccessedDateTime": "2023-10-05T08:30:15Z" } }Note: You’ll need the target file’s ID (which you can grab from the Recent API’s results).
Use the Search API to retrieve multiple files with
lastAccessedDateTime
If you need this property for multiple files matching a query, use the search endpoint with$select:GET https://graph.microsoft.com/v1.0/me/drive/root/search(q='your-search-term')?$select=id,name,fileSystemInfoThis returns a list of matching files, each including the full
fileSystemInfoobject.Leverage Delta Query for ongoing access event tracking
For continuous monitoring of file access events, use Delta Query to subscribe to drive changes. This lets you capture updates tolastAccessedDateTimeas they occur, though it requires setting up a subscription and handling change notifications.
A quick heads-up: lastAccessedDateTime might have some latency in updating, and not all client applications trigger this field to sync (e.g., some older desktop apps might not push access times to OneDrive).
内容的提问来源于stack exchange,提问作者Dogu Arslan

