How to filter children in a drive folder using nodejs microsoft-graph-client api

Nicolas ESPIAU 25 Reputation points
2024-03-27T15:24:31.66+00:00

I need to list the children of some drive and to filter them by lastModifiedDateTime, but the filter creates errors:

  const result = await azClient.api(`/drives/${driveId}/items/${folderId}/children`)
    .filter("lastModifiedDateTime ge '2022-05-20T13:30:41Z'")
    .get()

Returns:

{"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 'Equal'.","innerE`` rror":{"date":"2024-03-27T15:08:30","request-id":"8ae09b78-49cb-4559-ae24-abb8de6bb5aa","client-request-id":"4664652e-9cda-0cef-5444-a865a17daa8f"}}

While

const result = await azClient.api(`/drives/${driveId}/items/${folderId}/children`)
  .filter("lastModifiedDateTime eq 2022-05-20T13:30:41Z")
  .get()

Returns:

{"code":"invalidRequest","message":"Invalid request","innerError":{"date":"2024-03-27T15:23:00","request-id":"f2586479-93f7-4cfe-9644-21368115462b","client-request-id":"2ab756ba-a8ee-55c2-f95e-1d2fc4c98b75"}}

How to use dateTime filters properly?

Note: the same code without the filter option works fine and returns all the children.

Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 40,471 Reputation points Microsoft External Staff
    2024-03-28T02:54:31.48+00:00

    Hi @Nicolas ESPIAU,

    As far as I know, the /children endpoint does not support the $filter parameter for the time being, it currently only supports $expand, $select, $skipToken, $top and $orderby query parameters. You can check the description of the official doc.


    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.

    0 comments No comments

0 additional answers

Sort by: Most helpful

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.