List Messages: unable to filter by internetMessageId

Copper Contributor

Hi everyone,

 

I spent almost a day testing and trying to figure out how to filter a list of emails based on the InternetMessageId when using the List Messages Graph API, but I failed so far.

I am referring to this Microsoft support article and I looked for examples in several Microsoft and non-Microsoft forums, but nothing is working for me.

 

In my PowerShell test environment I can successfully filter the desired InternetMessageId from Exchange Online through the Get-MessageTrace cmdlet. 

Then I'm using an Invoke-RestMethod to make a HTTP (GET) call using the retrieved InternetMessageId in the filter, but instead of filtering the results, the output keeps including a list of 10 emails.

 

This is how I am formatting my request: 

 

Invoke-RestMethod "https://graph.microsoft.com/v1.0/users/$sender/messages?$filter=internetMessageId eq 'email address removed for privacy reasons'" -Method 'GET' -Headers $headers

 

 

I tried to include the internetMessageId in angle brackets and in its URL encoded version as shown below, but none of these formats solved my filtering problem, I'm still presented an unfiltered list of emails:

 

'<email address removed for privacy reasons>'

'%3CXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX%40XXXXXXXXXXXXX.xxxxxxxx.xxxx.outlook.com%3E'

 

 

Am I missing any escaping requirement?

 

Any input will be much appreciated. Thanks in advance.

 

 

0 Replies