Dec 26 2022 03:22 AM - edited Dec 26 2022 03:23 AM
I have been using Graph API to read messages from a selected mailbox like below.
$url = https://graph.microsoft.com/v1.0/users/email address removed for privacy reasons/messages?filter=((ReceivedDateTime ge 2022-12-22T20:00:00Z) and (receivedDateTime le 2022-12-23T09:00:00Z))&count=true
$Messages = Invoke-RestMethod -Headers @{Authorization = "Bearer $($ConnectGraph.access_token)"} -ContentType application/json -Uri $URL -Method Get
I assume that $Messages.'@odata.count' will return the count of messages fetched.
I then use a loop to retrieve the actual messages making use of $messages.value and taking note of the presence of $messages.'@odata.nextLink'
My finding is:
1) usually $Messages.'@odata.count' is greater than the actual number of messages retrieved.
2) sometimes the 2x counts matched
3) The actual messages (not just count) retrieved is 100% the same as the search result by using Advanced Find in Outlook.
Does anyone have similar experience?
Dec 26 2022 06:50 AM
Jan 06 2023 02:39 AM - edited Jan 06 2023 02:40 AM
Thanks Vasil for your response.
BTW I really appreciate all your contributions to the O365 community.
As far as this thread goes, maybe I did not express myself correctly.
I am aware that @odata.count contains the total number of messages that should be returned.
However, as I fetch each page (usually 10 items except the last fetch) of messages (based on presence of @odata.nextLink, sometimes I found out that the total messages fetched is less than the @odata.count.