Microsoft Graph me/messages returning incorrect @odata.nextLink $skip value

Dan Wahlin 21 Reputation points Microsoft Employee
2021-07-06T18:37:40.387+00:00

I'm working on some Microsoft Graph messaging code that targets .NET Core. It uses Me.Messages and skips through 5 messages at a time using $top and $skip. Everything works great until I get to the end of the messages and then I get a really strange issue with $skip.

After paging through the first few pages the $skip value jumps from 25 (there are records available with that value) to 191 (apparently when it's out of messages) rather than setting NextPageRequest to null or something along those lines (not passing back a @odata.nextLink value). The image below makes it more clear.

112287-skip-value-with-messaging.png

Any reason why the $skip value would jump from 25 to 191? If I set $skip to something like 30, 50, or 100 I just get the 5 records that $skip=25 would give me. If I set $skip=190 I get the last record shown when $skip=25 is set. I'm confused by it at this point. The code I'm using can be found here:

https://github.com/DanWahlin/DotnetCoreRazor-MicrosoftGraph/blob/main/Graph/GraphUtils.cs#L84

Something similar to this can also be emulated directly in Graph Explorer with the default account:

https://developer.microsoft.com/en-us/graph/graph-explorer?request=me%2Fmessages%3F%24select%3Dsubject%2CbodyPreview%2CreceivedDateTime%26%24top%3D5%26%24orderby%3DreceivedDateTime%26%24skip%3D0&method=GET&version=v1.0&GraphUrl=https://graph.microsoft.com

112239-skip-value-2.png

I'm not sure if I'm missing how this is supposed to work or if the API isn't returning correct values for @odata.nextLink $skip.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,515 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Waldek Mastykarz 1 Reputation point Microsoft Employee
    2021-07-20T06:16:44.163+00:00

    This behavior is intentional. There are other elements stored in the mailbox that need to be skipped which is why the skip value isn't continuous. The recommendation is to use the value from the nextLink as-is and not construct skip links manually.