Graph API filter parameter not parsing

Tayllor Myxter 25 Reputation points
2025-01-09T20:46:26.8+00:00

I have been in the process of updating from V2 to V3 (5.68). I had a V3 project working 2 weeks ago, but the last 2 days I have been getting errors with the date filter. I pack in the date into a query....

`public string[] PROPERTIES_FOR_HEADER_QUERY = new string[] { "id","internetMessageHeaders",internetMessageId","importance","subject","toRecipients","ccRecipients","bccRecipients","hasAttachments","sender","parentFolderId","receivedDateTime","sentDateTime" };`

var mailResponse = await graphClient.Me.Messages

.GetAsync(x => { x.QueryParameters.Filter = "(receivedDateTime gt 2024-12-25T10:00:00Z)"; });

}

As of this week, I'm getting a Syntax error: character '2' is not valid at position 21 in '(receivedDateTime ge 2024-12-25T10:00:00Z)'.

The date format has worked for years. Just to verify, I ran to Graph explorer and the date format still works...

https://graph.microsoft.com/v1.0/me/messages?$filter=(receivedDateTime ge 2024-12-25T10:00:00Z)

graph-success

So why is the date format an issue for the graph library now?

Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. CarlZhao-MSFT 46,371 Reputation points
    2025-01-10T08:38:07.35+00:00

    Hi @Tayllor Myxter

    Your code snippet works for me, and I don't see anything wrong with it.

    User's image

    As a test, try replacing the original code snippet with the one returned in the Graph Explorer and try again.

    User's image

    Hope this helps.

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

    1 person found this answer helpful.

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.