BigDataFiles
BigDataFiles

Reputation: 185

How to use receivedDateTime in Graph API Request?

I am trying to use the receivedDateTime filter clause when calling the Graph API, but I'm running into issues when I use the exact datetime. For example, when I try running this API call:

GET https://graph.microsoft.com/v1.0/me/mailFolders/Inbox/messages?$filter=receivedDateTime ge '2022-05-23T12:29:00'&$orderby=receivedDateTime%20ASC&$top=100&$skip=0

I get a 400 bad request (the specific error mentions "bad filter clause"). But it works when I run this one:

GET https://graph.microsoft.com/v1.0/me/mailFolders/Inbox/messages?$filter=receivedDateTime ge 2022-05-23'&$orderby=receivedDateTime%20ASC&$top=100&$skip=0

What can I do if I want to use the exact datetime in the filter clause, or is this even possible?

Upvotes: 0

Views: 3945

Answers (1)

scottwtang
scottwtang

Reputation: 2040

You need to append the Z in the ISO 8601 time format, where Z represents the zone designator for the zero UTC offset. (e.g. 2022-05-23T11:59:59Z)

https://graph.microsoft.com/v1.0/me/mailFolders/Inbox/messages?$filter=receivedDateTime ge 2022-05-23T11:59:59Z

Upvotes: 2

Related Questions