Search code examples
onenoteonenote-api

Keep getting 429 (Too Many Requests) throttling errors


I tried to engage with the API team via Twitter but I've not had a response and development is grinding to a halt here...

In short I keep getting a 429 when developing against the OneNote API, I know that this suggests I'm hitting the API too hard, but I'm not.

At worst I'm doing maybe 1 or 2 requests per minute, manually invoked by me as I develop. Sometimes I'll leave it 10-15 minutes between calls, sometimes this works, sometimes not.

I've been working on a particular problem the last few days. In my code I make a call to get all notebooks, sections & section groups in a single query (filtered to only return data from certain notebooks)

I then make a second call to get all updated pages for those notebooks. I've been fiddling with the filter string to get this second call working (which I now think I have), but 9 times out of 10 I get the 429 on this second API call.

Is there some way of getting my user account whitelisted please?

FWIW this is my second query (the spaces normally get encoded):

/me/notes/pages?count=true&top=100&expand=parentNotebook,parentSection
&filter=(parentNotebook/id eq '{GUID}' or parentNotebook/id eq '{GUID}' or parentNotebook/id eq '{GUID}') and lastModifiedTime gt 2016-08-05T11:34:09.000Z

This does work as I'd expect, the date clause is working now, but I can only test very occasionally as I get the 429.

Incidentally if I run my second filter through the API console I get a 504 "Proxy request timeout", every time. This has been since I've added the parenthesis around the notebook predicate.

So I'm pretty much unable to continue development, how do I resolve this please?


Solution

  • As a short term workaround, please try the following:

    Instead of one query:

    /me/notes/pages?count=true&top=100&expand=parentNotebook,parentSection&filter=(parentNotebook/id eq '{GUID}' or parentNotebook/id eq '{GUID}' or parentNotebook/id eq '{GUID}') and lastModifiedTime gt 2016-08-05T11:34:09.000Z
    

    Remove the "count=true" (are you using this?) and leave only one parentNotebookId filter. The results will be by default ordered by LastModifiedTime descending (most recent first).

    Perform this query for all the notebooks you're interested in:
    /me/notes/pages?top=100&expand=parentNotebook,parentSection&filter=parentNotebook/id eq '{GUID}'