Ivan
Ivan

Reputation: 31

Getting files modified after a provided date - SharePoint and OneDrive

I'm trying to get all the files modified after a provided date for a SharePoint site or an OneDrive.

I navigate recursively through all the children for a drive but the /children endpoint does not support a filter.

Using drive/list/items has the same filtering limitations.

I looked at the /delta endpoint and it has the option to provide a date([example](https://learn.microsoft.com/en-us/graph/api/driveitem-delta?view=graph-rest-1.0&tabs=http#example-4-retrieving-delta-results-using-a-timestamp)) but I noticed the date can't be older than 2 months and the results can be older then provided date.

I tried using /search, but I got no results:

drives/{'id'}/root/search(q='lastModifiedDateTime ge 2023-07-31T18:56:29Z')

Questions:

Is there a way to get files modified after a provided date for SharePoint or OneDrive?

Am I stuck going recursively over the children and performing the filtering on my end?

Is there at least an endpoint to get all the data without recursive queries?

Upvotes: 2

Views: 850

Answers (1)

user2250152
user2250152

Reputation: 20788

I would prefer /search/query endpoint where you can search for drive items and limit searching to a specific site and filter by date.

POST https://graph.microsoft.com/v1.0/search/query
{
    "requests": [
        {
            "entityTypes": [
                "driveItem"
            ],
            "query": {
                "queryString": "(LastModifiedTime>2023-12-25 AND path:\"https://contoso.sharepoint.com/sites/siteName\")"
            }
        }
    ]
}

Upvotes: 0

Related Questions