title: OneNote REST API - How to deal with a "502 Bad Gateway" error?
body: <p>I asked this question on the OneNote Dev Blog, 
  <a href="http://blogs.msdn.com/b/onenotedev/archive/2016/01/13/onenote-api-throttling-and-best-practices.aspx" rel="nofollow">http://blogs.msdn.com/b/onenotedev/archive/2016/01/13/onenote-api-throttling-and-best-practices.aspx</a> - and Jorge suggested asking it again here.
  <br/><br/>I am able to create multiple Notebooks with the REST API using the <br/>
  POST ...beta/me/notes/notebooks/{master notebook}/copynotebook <br/>the calls are very fast.
  <br/><br/>Adding pages with <br/>POST ...beta/me/notes/pages/{template page}/copyToSection <br/>works fine and allows me to get the pageID.
  <br/><br/>This all works as expected until the number of notebooks gets over what seems like a small number of notebooks may be less than 50.
  After this any command to get pageIDs such as 
  GET .../beta/me/notes/sections/{sectionID}/pages?top=100"
  <br/>results in multiple "502 Bad Gateway" responses and occassionally gets through after looping for 10-15 minutes waiting for a "200 OK". <br/><br/>When the notebook count gets to about 100 all page calls fail either in my php script, Fiddler or Microsoft Graph Explorer. Deleting the Notebooks returns functionality.
  <br/><br/>I know there is a 5000 Notebook limit, but is there a lower limit for pages API functionality (sections and notebook calls continue to work).
  Is it possible to select only a subset of Notebooks to be "active" to reduce the overhead on the API call?
  <br/><br/>My workaround at present (that I'm experiementing with) is to use the OneDrive API to download or move the NoteBooks out of OneDrive to accomplish the same thing - is there another approach?</p>