Share via

I need to fix this query https://graph.microsoft.com/v1.0/users$select=id&$count=true&$expand=messages($filter=from/emailAddress/address+endsWith+'@.com'+and+toRecipients/emailAddress/address+endsWith+'@.com')

Babetecno SAT 0 Reputation points
2023-04-18T13:46:30.0866667+00:00

This query is for obtain the amount of mails a user sends in my organization but give me an error i need to fix can someone help me with this?

Microsoft Security | Microsoft Graph

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-04-19T14:48:40.4466667+00:00

    Hi Babetecno SAT, Thank you for reaching out.

    Please note that endsWith parameters does not always work with certain OData query parameters https://github.com/microsoftgraph/microsoft-graph-docs/issues/4331  github post endswith operator support

    However upon some testing we were able to get the query working as such: https://graph.microsoft.com/v1.0/users/<User-GUID>/messages?$count=true&$filter= (contains(from/emailAddress/address,'.com')  and contains(to/emailAddress/address,'.com')) Note that a user guid is to be provided to the messages resource type so that the object is filterable. Further an item oData.count value will have the count value of the returned item.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.