How retrieve all files from sharepoint document library - "Shared Documents" based on last modified date using Graph API?

VIPPALA MADHAVA REDDY 25 Reputation points


Get all the files from the Sharepoint folders recursively (including sub-folders at all levels) that were modified after a specific date, using Graph API.

I have tried different methods, but none worked as expected. I am able to achieve a little progress with the below procedure but got an error- tooManyResources.

Steps I followed:

Following the below procedure, I am able to get files from Teams Wiki Data document library (list type), but the same is not working for Shared Documents it is giving this error code - tooManyResources.

  •<site-id>/lists/ - get all lists of the site.
  • There are two document library type lists in the response - Teams Wiki Data and Shared Documents. Noted ids of both the lists.
  •<site_id>/lists/<list_id>/items - used this without any query parameters and able to see results.
  • For the Shared Documents library, I can see all the results from sub-folders also. For Teams Wiki Data few items are returned, I'm not sure why it so, maybe it has only few items in it.
  • Again now, added these query parameters to the request.

Query Parameters

    "Prefer": "HonorNonIndexedQueriesWarningMayFailRandomly",
    "$filter": "fields/Modified ge '2022-03-08T08:23:03Z'"
  • For Teams Wiki Data it gives a convincing response. No errors and I can see some documents and folders.
  • But for Shared Documents, the same request gives following error-

Error Response

{'code': 'notSupported',
 'innerError': {'client-request-id': '<>',
                'code': 'tooManyResources',
                'date': '2023-11-09T16:12:13',
                'request-id': '<>'},
 'message': 'The request is unprocessable because it uses too many resources'}
  • On updating query parameters as below, gives a different error.
    "Prefer": "HonorNonIndexedQueriesWarningMayFailRandomly",
    "$filter": "lastModifiedDateTime ge '2022-03-08T08:23:03Z'"


    "error": {
        "code": "BadRequest",
        "message": "Invalid filter clause: A binary operator with incompatible types was detected. Found operand types 'Edm.DateTimeOffset' and 'Edm.String' for operator kind 'GreaterThanOrEqual'.",
        "innerError": {
            "date": "2023-11-09T17:55:52",
            "request-id": "<>",
            "client-request-id": "<>"


  • Please let me know, if any workaround to resolve the above errors - tooManyResources and BadRequest - incompatible types.
  • Please suggest any other possible ways to achieve the aforementioned requirement using Graph API (preferred or any better alternative)


Thanks in advance.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
9,169 questions
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
8,611 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,543 questions
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 27,031 Reputation points Microsoft Vendor


    Per my test, you could use following search api to get files by date.

    POST /search/query
    Content-Type: application/json
      "requests": [
          "entityTypes": [
          "query": {
    "queryString":"path:\"\" AND LastModifiedTime < date"


    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.