question

StevenKaplan-1172 avatar image
0 Votes"
StevenKaplan-1172 asked MichaelHan-MSFT commented

getActivitiesByInterval Returns Empty Value Set For A Modified File

I am trying to use the getActivitiesByInterval method (docs: https://docs.microsoft.com/en-us/graph/api/itemactivitystat-getactivitybyinterval?view=graph-rest-1.0&tabs=http) on a set of pdf files in SharePoint to determine various access stats. This method, however, is failing a main sanity check. When viewing just /drives/{driveID}/items/{itemID}, it correctly shows that the file was created on a certain day and modified a few days later. At the very minimum, I should then be seeing the creation and the edit with getActivitiesByInterval on those respective days. Instead, all I get is

{'@odata.context': 'https://graph.microsoft.com/v1.0/$metadata#Collection(itemActivityStat)', 'value': []}

for /drives/{driveID}/items/{itemID}/getActivitiesByInterval(startDateTime='2021-06-29',endDateTime='2021-07-07',interval='day'). Is there some lag period before this information is available or something? The file was created around a week ago and modified two days ago. This seems to be a contradiction otherwise. Any help getting this information would be greatly appreciated!

sharepoint-devmicrosoft-graph-insights
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MichaelHan-MSFT avatar image
0 Votes"
MichaelHan-MSFT answered StevenKaplan-1172 commented

Hi @StevenKaplan-1172,

I did a test in graph explorer, this works fine on my end. As the below screenshot shows. In the result, everyday should have a record even we did not access the file that day.

112916-image.png


If an Answer is helpful, please click "Accept Answer" and upvote it.
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.



image.png (57.2 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Michael,

Thank you for your swift reply! I'm not sure what to say...I tried it both with python and with graph explorer and I get the same result. Again, this is with a pdf file.

Is it possible that this functionality only works for Office-type files (e.g. docx, xlsx)? I tried the same thing with a new Excel file and did get the expected result:

{'@odata.context': 'https://graph.microsoft.com/v1.0/$metadata#Collection(itemActivityStat)',
'value': [{'@odata.type': '#microsoft.graph.itemActivityStat',
'aggregationInterval': 'None',
'startDateTime': '2021-07-07T00:00:00Z',
'endDateTime': '2021-07-07T23:59:59Z',
'access': {'actionCount': 0, 'actorCount': 0, 'timeSpentInSeconds': 0},
'incompleteData': {'wasThrottled': False,
'resultsPending': False,
'notSupported': False}},
{'@odata.type': '#microsoft.graph.itemActivityStat',
'aggregationInterval': 'None',
'startDateTime': '2021-07-08T00:00:00Z',
'endDateTime': '2021-07-08T23:59:59Z',
'access': {'actionCount': 1, 'actorCount': 1, 'timeSpentInSeconds': 0},
'incompleteData': {'wasThrottled': False,
'resultsPending': False,
'notSupported': False}}]}

Well, I would have expected both 'create' and 'edit' itemActionStats instead of just access. Maybe that's a permissions thing?

0 Votes 0 ·
MichaelHan-MSFT avatar image
0 Votes"
MichaelHan-MSFT answered MichaelHan-MSFT commented

Hi @StevenKaplan-1172,

I did more test on my end. And I could reproduce the issue on some files. Below is my finding, hope it helps you.

The getActivitiesByInterval method can only get 'access' event, we could not get other events like 'create' or 'edit'. If we create the file(usually upload) but never access it, we would get empty value in the result.

You could try to acess the pdf file, then make a request again. Thus you would get value in the result.


If an Answer is helpful, please click "
Accept Answer" and upvote it.
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.*

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@StevenKaplan-1172,
Is there anything update? I am willing to hear from you.

0 Votes 0 ·