Filtering/query for lastDateModified in SharePoint using GraphAPI

Andrei Nagy 0 Reputation points
2024-07-16T12:41:39.1933333+00:00

Hello,

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.

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".

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"

      }

    }

  ]

}

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,767 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,603 questions
{count} votes

1 answer

Sort by: Most helpful
  1. CharanyaB-MSFT 1,891 Reputation points Microsoft Vendor
    2024-07-16T18:33:27.5666667+00:00

    Hello @Andrei Nagy,

    Thanks for reaching Microsoft.

    You can utilize the $filter query parameter to retrieve a list of documents that have been modified since a specific date. The following API may assist you in this process: GET https://graph.microsoft.com/v1.0/sites/{site-id}/drives/{drive-id}/items?$filter=lastModifiedDateTime ge {dateTime}. Also refer the below screenshot:User's image

    Documentation reference: https://video2.skills-academy.com/en-us/graph/filter-query-parameter?tabs=http

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


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.