Trouble with Filtering in MS Graph API Query for Messages

Jeff 0 Reputation points

Hi everyone,

I am having difficulty in filtering messages based on the receivedDateTime field while querying the Microsoft Graph API. I am aiming to retrieve messages for a particular user, filtered by a specific date.

However, I keep encountering a 400 Bad Request error whenever I include the ?$filter=receivedDateTime ge {date} in the request URL.

Here's the exact URL format I've been trying:{user_id}/messages?$filter=receivedDateTime ge 2023-10-01T00:00:00

And the error I receive is:

<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request</h2>
<hr><p>HTTP Error 400. The request is badly formed.</p>

I have tried various date formats and url encodings. I am able to execute other queries without the filter successfully, so I believe the rest of my request setup is correct.

Can anyone provide insight on the correct way to format this filter, or point me to where in the documentation this is explained?

Thank you for your assistance!

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,781 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vasil Michev 96,436 Reputation points MVP

    You are not using the proper format for a receivedDateTime value. Try this:{userId}/messages?$filter=receivedDateTime ge 2023-10-01T00:00:00z