Search code examples
onenote-api

OneNote API: "Query operation not accepted" when filtering a pages GET


I'm attempting to get a list of pages by notebook from the OneNote REST API.

One option is to iterate over a list of sections and GET pages per section using /api/v1.0/notes/sections/[ID]/pages

Instead, to reduce the number of requests I'm filtering a call to /v1.0/me/notes/pages by parentNotebook/id but I'm getting, for example:

The query operation(s) parentNotebook/id eq [ID] 
OR parentNotebook/id eq [ID] OR parentNotebook/id eq [ID] not supported.
http://aka.ms/onenote-errors#C20106

Error #20106 states:

Your request contains a query operator that is not supported. See OneNote API reference.

My brief reference to the OData 4.0 docs leads me to believe that parentNotebook/id is the correct syntax, so what am I doing wrong please?

UPDATE

So, it does work, if I do one at a time; the problem seems to be the OR?

Can I change my filter to include multiple notebooks or should I be doing an API call per notebook?

Ironically when I did do a call per notebook I got my first http 429 throttling hand slap, though adding a 2 second pause between requests seemed to solve that.


Solution

  • Just tried the following in the interactive console and got back a successful 200 response.

    GET https://www.onenote.com/api/v1.0/me/notes/pages?filter=parentNotebook/id eq '0-C6703B3BE9D6A5E0!317' or parentNotebook/id eq '0-D8E91FC12048CF4A!515'
    
     *NOTE* replace the above notebook ids with your own ids.
    

    So filtering on multiple notebooks using or expression is possible.