Pagination on the OneNote Graph API - Missing @odata.nextLink

Hieu Phan Trung 20 Reputation points
2023-04-21T05:59:16.6733333+00:00

Hi guys, I'm working with Onenote through Graph API and today I saw the @odata.nextLink was missing when using the $top to limit the result. Does anybody know if this change was planned or if this is a bug in Onenote API :(.233107699-dd03bfdb-8d1b-4f16-a6bf-49ee06940a96[1]

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

Accepted answer
  1. Anonymous
    2023-04-21T06:41:46.1533333+00:00

    Hello Hieu Phan Trung,

    Thanks for reaching out!

    It is an expected behavior that for MS Graph OneNote API @odata.nextLink is not expected if $top is being used. As it is a client-side paging you should use $skip as needed. Please refer this link for more details about pagination Paging Microsoft Graph data in your app - Microsoft Graph | Microsoft Learn

      • To get @odata.nextLink you can refer to the below steps:
      • To get top 3 results in the response the Graph call will be https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks?$top=3.
    • Now to get the next set of results please use the $skip parameter along with $top.
      • $skip-Indexes into a result set.$top-Sets the page size of results.https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks?$skip=3&$top=3.
      • The above Graph call will give the results from count 4 to 6 because we use the skip=3 and top=3.
      • Similarly, to get the next set of 3 results https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks?$skip=7&$top=3.
      • This Graph call will return the results from 7 to 9. Please follow the process till last count.

    Hope this helps.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have further questions about this answer, please click "Comment".

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. 2024-03-04T12:51:50.4566667+00:00

    Yes I accept the solution

    0 comments No comments