getActivityByInterval returns all 0 values for timeSpentInSeconds

Ivo Angelov 20 Reputation points
2023-12-14T10:20:22.8233333+00:00

Looking to fetch Activity data for a few dozen SharePoint sites through the Graph API and hitting a bit of a snag. The response I always get to a simple "" call seems to have the "timeSpentinSeconds" values (even though these aren't mentioned in the documentation). I'd need the data broken down by the hourly level, rather than using the "analytics" endpoint, which gives you a choice of Last7Days / AllTime. Any ideas why this is happening?

Sample response received:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(itemActivityStat)",
    "value": [
        {
            "@odata.type": "#microsoft.graph.itemActivityStat",
            "aggregationInterval": "None",
            "startDateTime": "2023-10-09T00:00:00Z",
            "endDateTime": "2023-10-09T00:59:59Z",
            "access": {
                "actionCount": 4,
                "actorCount": 1,
                "timeSpentInSeconds": 0
            },
            "incompleteData": {
                "wasThrottled": false,
                "resultsPending": false,
                "notSupported": false
            }
        },
        {
            "@odata.type": "#microsoft.graph.itemActivityStat",
            "aggregationInterval": "None",
            "startDateTime": "2023-10-09T01:00:00Z",
            "endDateTime": "2023-10-09T01:59:59Z",
            "access": {
                "actionCount": 7,
                "actorCount": 3,
                "timeSpentInSeconds": 0
            },
            "incompleteData": {
                "wasThrottled": false,
                "resultsPending": false,
                "notSupported": false
            }
        },
...
...
...
        {
            "@odata.type": "#microsoft.graph.itemActivityStat",
            "aggregationInterval": "None",
            "startDateTime": "2023-10-10T22:00:00Z",
            "endDateTime": "2023-10-10T22:59:59Z",
            "access": {
                "actionCount": 15,
                "actorCount": 2,
                "timeSpentInSeconds": 0
            },
            "incompleteData": {
                "wasThrottled": false,
                "resultsPending": false,
                "notSupported": false
            }
        },
        {
            "@odata.type": "#microsoft.graph.itemActivityStat",
            "aggregationInterval": "None",
            "startDateTime": "2023-10-10T23:00:00Z",
            "endDateTime": "2023-10-10T23:59:59Z",
            "access": {
                "actionCount": 3,
                "actorCount": 1,
                "timeSpentInSeconds": 0
            },
            "incompleteData": {
                "wasThrottled": false,
                "resultsPending": false,
                "notSupported": false
            }
        }
    ]
}
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,072 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,591 questions
0 comments No comments
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 32,636 Reputation points Microsoft Vendor
    2023-12-15T02:48:19.8933333+00:00

    Hi @Ivo Angelov,

    Currently Graph doesn't support to get the Activity data by hourly level. The api only get the day level data. I feel regretful to inform you that it turns out to be a by-design one.

    It is highly recommended that you can vote this ticket. Many features of our current products are designed and upgraded based on customers’ feedback. With requirements like this increase, the problem may well be released in the future. Thanks for your understanding.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Wajid Anwar 10 Reputation points
    2024-05-21T13:20:15.69+00:00

    Even with interval set to 'day', timeSpentInSeconds is retruning 0 value

    0 comments No comments