1

I am using the below filters for the graph api request.

?$filter=lastModifiedDateTime ge 2023-10-06T06:48:54Z&$select=name,lastModifiedDateTime,@microsoft.graph.downloadUrl

I am getting the following error:

{
    "error": {
        "code": "invalidRequest",
        "message": "Invalid request"
    }
}

The request cannot be fulfilled due to bad syntax.

This is the list of items without the filter condition.

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(driveItem)",
    "value": [
        {
            "@odata*.etag": "***",
            "lastModifiedDateTime": "2023-10-06T06:48:54Z",
            "name": "Archive"
        },
        {
            "@odata.etag": "**",
            "lastModifiedDateTime": "2024-05-07T06:53:10Z",
            "name": "Pricing_Reference_Data_from_Source_Report.xlsx"
        }
    ]
}

Could you please help me understand what the issue with the above syntax is? Thanks in advance.

8
  • Does putting single quotes around the date do something? '2023-10-06T06:48:54Z' Commented Nov 9 at 17:43
  • I get this error { "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": "2025-11-09T17:02:32", "request-id": "6f2740ce-e395-4d49-94f4-949d487624af", "client-request-id": "6f2740ce-e395-4d49-94f4-949d487624af" } } } Commented Nov 9 at 18:14
  • And adding 'datetime' before the date? datetime'2023-10-06T06:48:54Z' Commented Nov 9 at 18:27
  • This error: { "error": { "code": "BadRequest", "message": "Invalid filter clause: Syntax error at position 55 in 'lastModifiedDateTime ge datetime '2023-10-06T06:48:54Z''.", "innerError": { "date": "2025-11-09T18:30:51", "request-id": "b599b2c9-5105-4472-9374-8525b63c41e6", "client-request-id": "b599b2c9-5105-4472-9374-8525b63c41e6" } } } Commented Nov 9 at 18:31
  • 1
    Please share the endpoint you are calling. Commented Nov 9 at 18:45

1 Answer 1

1

For your query to work, you need to specify the Prefer request header with the value TryFilterLastModifiedDateTimeTimeWarningMayFailRandomly,apiversion=2.1.

GET /v1.0/sites/{site_id}/drives/{drive_id}/root:/{folder_name}:/children?$filter=lastModifiedDateTime ge datetime '2023-10-06T06:48:54Z'&$select=name,lastModifiedDateTime,@microsoft.graph.downloadUrl

Prefer: TryFilterLastModifiedDateTimeTimeWarningMayFailRandomly,apiversion=2.1

The apiversion=2.1 will ensure that your request is routed to internal beta SharePoint API . Because it's internal beta API, it's not recommended for the production.

The TryFilterLastModifiedDateTimeTimeWarningMayFailRandomly will ensure that you can filter drive items by lastModifiedDateTime, but as the name says, the filtering can fail randomly.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot. This seems to be working. Another question unrelated to the previous one: I am adding @microsoft.graph.downloadUrl to the select param, but I don't get it in the response. I get @odata.etag instead. What is the reason for that? How can I select @microsoft.graph.downloadUrl

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.