Search code examples
microsoft-graph-apionenoteonenote-apimicrosoft-graph-onenote

How to retrieve pages filtered by a tag from OneNote API?


Some of my pages have a OneNote Tag in it https://learn.microsoft.com/en-us/graph/onenote-note-tags

I would like to retrieve only pages that contain a specific tag from a notebook.

Currently, I would need to

  1. Get all the sections from a notebook
  2. Get all the pages from a section
  3. Get all content from pages
  4. check if it contains data-tag="important" (example)

Is there a better way of doing this via the ms graph? (possibly via a combination of expand/filter)

Best


Solution

  • To get the pages in a notebook use the HTTP call below.

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

    To compare the data-tag="important" is present in the content or not, it is not possible as of now but if your data is small you can use a work around by calling the below HTTP call and compare it for each page on your end.

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

    If you have tons of data, it would be better to raise a Uservoice for this scenario by going to the Microsoft Graph Feedback Forum so that it can be implemented in the future.