It is already a week and I can’t still find a way to get some documents from my SharePoint and be able to filter by lastModifiedDate.
I am working on an application for getting documents from SharePoint using GraphAPI. Given a root folder from SharePoint, I want to list all documents that where modified since a arbitrary date.
For example in my “Shared Documents” drive, I have a folder “TestSharePoint” and some files there, that I want to retrieve with filter by lastModifiedDate.
I try using something like this https://graph.microsoft.com/v1.0/sites/{siteId}/drives/{driveId}/root/search/queryI am getting “General exception while processing”. Even if I have like a basic query just for a string, like, the below one, it still returns exception.
{
"requests": [
{
"entityTypes": [
"driveItem"
],
"query": {
"queryString": "contoso"
}
]
}
]
}
For me, the above call seems more logical, because I can have many tenants each with different sites/drives, and like this I can point to the exact site and drive.
If I use this call https://graph.microsoft.com/v1.0/search/query with body, I am getting exception “SearchRequest Invalid (Region is required when request with application permission.)”
{
"region": "GBR",
"requests": [
{
"entityTypes": [
"driveItem"
],
"query": {
"queryString": "path:"https://{tenant}.sharepoint.com/sites/{someSites}/Shared%20Documents/" AND LastModifiedDateTime > 2024-07-16T00:00:00Z"
}
}
]
}
But, I am am logged into the the developer.microsoft.com, into Graph explorer, requests with query, without specify the region, works fine, but I don’t know if I am missing some permissions or what happens.
My permissions are Microsoft Graph Files.Read.All, Sites.Selected, User.Read
I tried different variations and examples but could not make it work, maybe I am missing permissions but I am not sure what I am missing. Also maybe the api is not implemented.
Andrei Nagy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.