filter dates on channel messages returns "BadRequest"

Ben Zhang 25 Reputation points

I am trying to get Team channel messages filter on certain dates, e.g. createdDateTime, by:<team-id>/channels/<channel-id>/messages?$filter=createdDateTime ge '2023-05-29T07:49:22.246Z'.

But I got response:

    "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-07T21:48:18",
            "request-id": "4311fc38-52f0-4921-8917-8502e009a741",
            "client-request-id": "4757f844-b325-de95-c1ec-4a627e717d85"

There are a few threads on SO, etc. mentioning using/Not using '' on the datetime value, or use ""datetime" to wrap the value. But nothing really works.

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
9,394 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,107 questions
0 comments No comments
{count} votes

0 additional answers

Sort by: Most helpful