Compartir a través de


Change page level

Hi there,
In this Beta API update we are allowing developers to change the indentation level for a page (aka page level) programmatically.
For those of you who are unfamiliar with this feature, the following image shows how pages can be indented in three levels:

Here is a quick recipe for how to do this, followed by an example:

  • Get the ID of the page for which you want to change the indentation level.
  • Make sure to append the following headers to the request:
    • A valid Authorization header.
    • Content-Type set to application/json.
  • Use the PATCH verb.
  • The URL for the API is: https://www.onenote.com/api/beta/me/notes/pages/{id}
  • In the body of the request append the following JSON object:
    {"level":" {page level} "}
    Replace {page level} with 0, 1 or 2 where 0 means no indentation at all and 2 is the maximum indentation level.
  • Any response other than a 204 (HTTP no content) means that something went wrong.

Here's an example of what such a request might look like if we wanted to change the indentation level of a specific page to 1:

PATCH https://www.onenote.com/api/beta/me/notes/pages/1-567446387463478
Content-Type: application/json
Authorization: Bearer eyJ0eXAiOiJKV1...

{"level": "1"}

Gotchas:

  • The indentation level for the first page in a section cannot be changed, it only works starting at the second page and onwards (if attempted, the request will fail with an HTTP status of 400).
  • If the page above an indented page is moved to another location or deleted, the indented page will lose its indentation.
  • The only valid values for the level property are 0, 1, 2.
  • This API is still in Beta so please don't forget the /beta in the URL.
  • Please refer to the PATCH content API documentation for additional information about PATCH APIs.

You can use the following APIs to get the value of the current page level:

GET https://www.onenote.com/api/v1.0/me/notes/pages/{id}?pagelevel=true

Or

 GET https://www.onenote.com/api/v1.0/me/notes/sections/{id}/pages?pagelevel=true

Please note that you will have to append the pagelevel=true parameter to the request URL.

Let us know what you think on UserVoice, contact us on twitter @onenotedev, or ask questions tagged onenote on Stack Overflow.

Enjoy,
Yanir

Comments

  • Anonymous
    February 05, 2016
    is it possible to batch rename pages to either include some constant variable "WSJ" or modified date formated like "YYYY-MM-DD HHMMSS"?

  • Anonymous
    March 22, 2016
    sorry we don't have batching support in the APIs but individual pages can be renamed easily

  • Anonymous
    May 24, 2016
    Hi,We tried the above method to create subpage, but unfortunately we got an error saying "Bad-Request". The problem what we are facing is we don't know where exactly we need to add/append the JSON object i.e. "{"level": "1"}" to the request body.In patch command what should be the value of "Target"? Please help us out to break this.