We are syncing user's Outlook accounts by paginating through the /me/messages
endpoint in chronological order. Sometimes the API response will not include @odata:nextLink
even if there are more messages.
We are just using the $top
, $select
, $skip
, and $orderby
parameters.
For example, one account was paginated up to about 25,000 emails and then there was no nextLink
but the emails returned were over 6 months old so it was clear there were more emails since it is an active account. When I changed the $skip
parameter to a higher number the API showed newer emails and then correctly returned a nextLink
in the response.
Also we have the $top
set to 100 but in the response missing a nextLink
only 19 emails were returned (despite the emails being returned being over 6 months old and there being many newer emails), so there is some sort of gap in the messages being returned.
Calling the URL https://graph.microsoft.com/v1.0/me/messages?$top=100&$select=id,receivedDateTime,subject,bodyPreview,from,toRecipients,isDraft,sender&$skip=23352&$orderby=receivedDateTime asc
returns 19 emails from 2017-06-16 and there is no nextLink
in the response.
Calling the same URL but with $skip=24352
(skipping 1,000 ahead) returns 100 emails from 2017-06-17 to 2017-06-20 and has a nextLink
in the response so it is clear there actually were more emails and a nextLink
should have been present in the first response.
Please let me know if I am doing something wrong or if there is a way we can work around this, thank you!