Forum Discussion
Learn about the new Microsoft Stream - enhancing video across M365 built on top of SharePoint
Great stuff, happy to see that there are some needed improvements to the platform. I'm most excited about the ability to use the API to query files and built out some deeper analytics.
Can someone provide either a sample GET command or a snippet on how to retrieve view information for a file stored in OneDrive?
marekkoenig wrote:
Great stuff, happy to see that there are some needed improvements to the platform. I'm most excited about the ability to use the API to query files and built out some deeper analytics.
Can someone provide either a sample GET command or a snippet on how to retrieve view information for a file stored in OneDrive?
marekkoenig - You can use the /getActivitiesByInterval API: Get item activity stats by interval - Microsoft Graph v1.0 | Microsoft Docs
Example GET:
https://graph.microsoft.com/v1.0/me/drive/items/01AY6ADJYACCEFNHXAUJAKUQV4MY7MHFKB/getActivitiesByInterval(startDateTime='2020-08-26',endDateTime='2020-09-01',interval='week')
Will return this, 50 views in this time frame from 29 unique users.
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(itemActivityStat)",
"value": [
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2020-08-26T00:00:00Z",
"endDateTime": "2020-09-01T23:59:59Z",
"access": {
"actionCount": 50,
"actorCount": 29,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
}
]
}