Why onenote graph api not returning latest sections or pages

Habeeb Rahman 0 Reputation points
2024-06-30T16:19:04.8233333+00:00

I have a shared public url of onenote file starting "https://1drv.ms/o/{some_id}". I am trying to access the contents of that using graph api. I tried from graph explorer. First i got the notebook id using "/shares/{shared_id}/driveItem". Then made a request to "/me/onenote/notebooks/{notebook_id}/sections" to get sections. First i got error from api, but when i put "0-" before notebook_id i got the sections but which was not latest. I have retried many times. Then suddenly I got all latest sections. So I requested for pages under that sections using "/me/onenote/sections/{section_id}/pages". But i have tried many times and it still not returning pages under the sections. The result is empty array. On onenote website i can see that the file is synced already. What is the problem with onenote graph api? Why i am not getting latest pages? Am I doing anything wrong? Is there any way to read the onenote file in python, i mean some package?

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

1 answer

Sort by: Most helpful
  1. Yakun Huang-MSFT 1,870 Reputation points Microsoft Vendor
    2024-07-01T07:55:30.7133333+00:00

    Hi @Habeeb Rahman

    Following my tests, the API endpoint is functioning excellently. The test results are as follows:

    User's image

    Screenshot 2024-07-01 154414

    Please verify by reviewing my tests, particularly whether the section_id is accurate and if a page exists under the respective section.

    At the same time, you can also use the following request to query all pages, find your corresponding page, check the parent section id and name.

    https://graph.microsoft.com/v1.0/me/onenote/pages
    

    More information about the API can be found at this link:

    https://video2.skills-academy.com/en-us/graph/onenote-get-content

    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.

    0 comments No comments