Microsoft Graph OneNote get sections api does not returns next link when used with $top

Deepak Sharma 31 Reputation points
2023-07-12T06:00:16.87+00:00

We are using the following endpoint to list all sections of the notebook. If I specify $top=x, the response does not contain next link even if there are more sections.

Link to documentation:

https://learn.microsoft.com/en-us/graph/api/onenote-list-sections?view=graph-rest-1.0&tabs=http

Sample Request
https://graph.microsoft.com/beta/groups/e827f44c-4afc-44ce-b527-bebb98f4ac28/onenote/sections?$select=id&$top=2

Response:

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#groups('e827f44c-4afc-44ce-b527-bebb98f4ac28')/onenote/sections(id)",
    "value": [
        {
            "id": "1-294193e1-e2d4-4894-80e0-f4f3d6f031da"
        },
        {
            "id": "1-b61a5957-4e6d-4ca9-a171-f75c48dc9c82"
        }
    ]
}

In this example there are 3 sections in this notebook still the response doesn't have the next link.

We are seeing OneNote section calls takes a lot of time hence I want to improve the performance by specifying top 10 sections, but that does not work, even though the documentation says it supports OData Query Parameters.

https://learn.microsoft.com/en-us/graph/api/onenote-list-notebooks?view=graph-rest-1.0&tabs=http

OneNote
OneNote
A family of Microsoft products that enable users to capture, organize, and reuse notes electronically.
140 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
9,936 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 34,621 Reputation points
    2023-07-12T10:05:20.6033333+00:00

    Hi @Deepak Sharma

    This seems to be by design. For MS Graph OneNote API, using $top will not return @odata.nextLink. You need to combine $skip with $top to manually paginate.

    https://graph.microsoft.com/beta/groups/e827f44c-4afc-44ce-b527-bebb98f4ac28/onenote/sections?$select=id&$count=true&$top=2&$skip=2
    

    User's image

    Refer to similar thread: https://learn.microsoft.com/en-us/answers/questions/1251169/pagination-on-the-onenote-graph-api-missing-@odata.

    Hope this helps.

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