How can I filter messages in a Teams chat to a specific range accurately?

Joel Silver 0 Reputation points
2024-12-09T19:36:08.26+00:00

I would like to get Teams chat messages in an API call, but filtered to a specific date-time range. For some inexplicable reason, the filter based on the message's createdDateTime property does NOT allow specifying a start/lower boundary (ie, greater than). It only allows upper boundary (end of range/less than). If you look at the documentation for it, the query parameters allowed for filtering are lastModifiedDateTime and createdDateTime. However, only lastModifiedDateTime allows specifying greater than (gt) and less than (lt). For createdDateTime, only less than (lt) is allowed. There is no explanation for why this is.

How can I accurately get messages that were sent within a specific date range? The lastModifiedDateTime gets affected if the user edits their message, if other users react to the message with emojis, etc. That opens too many possibilities of getting inaccurate results (ie, messages can either be missed or incorrectly included).

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

1 answer

Sort by: Most helpful
  1. Anonymous
    2024-12-10T07:47:24.3366667+00:00

    Hello Joel Silver,

    Thank you for reaching out to Microsoft Support!

    According to the documentation, createdDateTime supports only lt operators, as you stated.

    User's image

    After the query there is a parameter that uses search, I hope it is useful for you, please see the documentation for details:

    https://learn.microsoft.com/en-us/graph/search-concept-chat-messages?tabs=http

    Hope this helps.

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


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.