{"id":1265,"date":"2016-09-11T21:16:00","date_gmt":"2016-09-12T04:16:00","guid":{"rendered":"https:\/\/officedevblogs.wpengine.com\/?p=1265"},"modified":"2021-11-15T11:31:02","modified_gmt":"2021-11-15T19:31:02","slug":"onenote-api-calls-fail-with-a-large-number-of-items-in-a-sharepoint-document-library","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/onenote-api-calls-fail-with-a-large-number-of-items-in-a-sharepoint-document-library\/","title":{"rendered":"OneNote API calls fail with a large number of items in a SharePoint document library"},"content":{"rendered":"<p>Hello world! Paresh Moradiya and Sri Srinivasan, members of the OneNote API team here. We&#8217;ve heard from some of you saying that you&#8217;re running into issues when accessing SharePoint-hosted notebooks in very large document libraries. We have come up with some instructions on how you can eliminate these OneNote API failures.<\/p>\n<h2><b>The problem<\/b><\/h2>\n<p>Applications call the OneNote REST API to create or access OneNote content in Office 365. Sometimes the OneNote API calls can fail when they are executed against SharePoint document libraries that contain a large number of items (items can be folders or files, some of which could be OneNote entities such as notebooks, sections or section groups).<\/p>\n<p>When working with SharePoint document libraries that contain a large number of items, the OneNote API service is subject to throttling measures implemented by SharePoint for the purposes of regulating resource usage. Under these circumstances, the user of the application may see an application-specific error. The application calling the OneNote API will itself receive one of the errors below:<\/p>\n<p>{\n&#8220;error&#8221;: {\n&#8220;code&#8221;: &#8220;10008&#8221;,\n&#8220;message&#8221;: &#8220;One or more of the document libraries on the user or group&#8217;s OneDrive contains more than 5,000 OneNote items (notebooks, sections, section groups) and cannot be queried using the API. Please make sure that none of the user or group&#8217;s document libraries contains more than 5,000 OneNote items. Please follow the link below for instructions on how to remedy this situation.&#8221;,\n&#8220;@api.url&#8221;: &#8220;<a href=\"http:\/\/aka.ms\/onenote-errors#C10008\">http:\/\/aka.ms\/onenote-errors#C10008<\/a>&#8221;\n}<\/p>\n<p>{\n&#8220;error&#8221;: {\n&#8220;code&#8221;: &#8220;10013&#8221;,\n&#8220;message&#8221;: &#8220;One or more of the document libraries on the user or group&#8217;s OneDrive contains more than 20,000 items and cannot be indexed for querying using the API. Please follow the link below for instructions on how to remedy this situation.&#8221;,\n&#8220;@api.url&#8221;: &#8220;<a href=\"http:\/\/aka.ms\/onenote-errors#C10013\">http:\/\/aka.ms\/onenote-errors#C10013<\/a>&#8221;\n}<\/p>\n<h2><b>The solution<\/b><\/h2>\n<p>To mitigate the OneNote API failures described above, you must first assess the\u00a0current state of the SharePoint document libraries on the SharePoint site and then take a few remedial steps based on the current state.<\/p>\n<h3><b>Assess the current state<\/b><\/h3>\n<p>Download the\u00a0<i>OneNote API Diagnostics<\/i>\u00a0tool available\u00a0<a href=\"https:\/\/github.com\/OneNoteDev\/OneNoteAPIDiagnostics\/tree\/master\/Tool\">here\u00a0<\/a>and follow the steps below.<\/p>\n<ol>\n<li>Enter the following\u00a0parameters into the tool\n<table cellspacing=\"0\">\n<tbody>\n<tr>\n<td><b>Parameter<\/b><\/td>\n<td><b>Description<\/b><\/td>\n<\/tr>\n<tr>\n<td>SharePoint URL<\/td>\n<td>The SharePoint site&#8217;s URL. For\u00a0example, a\u00a0user&#8217;s personal site might use the format\u00a0<code>https:\/\/&lt;&lt;Your Tenant&gt;&gt;-my.SharePoint.com\/personal\/&lt;&lt;Your email address - Replace all \".\" with \"_\"&gt;&gt;<\/code>\u00a0(contact your administrator for the format of your personal site&#8217;s URL)<\/p>\n<p>You can also enter the URL for a non-personal SharePoint site<\/td>\n<\/tr>\n<tr>\n<td>User<\/td>\n<td>Your Office 365 user name (email address)<\/td>\n<\/tr>\n<tr>\n<td>Password<\/td>\n<td>Your office 365 password<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li>Click the &#8220;Get Info&#8221; button. This will fetch the diagnostic information from the specified SharePoint site. The operation\u00a0may take a few seconds to process.<\/li>\n<\/ol>\n<p><b>NOTE<\/b>: The tool processes only the default document library on the SharePoint site by default (for a user&#8217;s personal site, this is the user&#8217;s OneDrive for Business). If the API issues above are not resolved by just targeting the default document library, you can choose the tool&#8217;s option to target all document libraries on the SharePoint site.<\/p>\n<h3><b>Take appropriate remedial steps<\/b><\/h3>\n<p>Based on the output of the diagnostics tool, you can take the remedial steps suggested below. These steps are applicable at a document library level. If you chose to target all document libraries on the SharePoint site, you will need to execute the remedial steps below on all the document libraries.<\/p>\n<p><b>Case 1: Items Count is greater than 20,000<\/b><\/p>\n<p>If Items Count is greater than 20,000 and File Type = false or HTML File Type = false, then you need to bring the item count in the document library to under 20,000. You can do this by moving items out of the document library to a different storage location (such as another user or group&#8217;s OneDrive). You can also delete the items that\u00a0are not required anymore.<\/p>\n<p>After\u00a0you have reduced the item count to under 20,000, rerun the tool to make sure the items count is less than 20,000. Click the &#8220;Build Index&#8221; button so the required indexes are built for the OneNote API to work properly.<\/p>\n<p><b>Case 2: Sections Count is greater than 5,000<\/b><\/p>\n<p>If Sections Count is greater than 5,000, then you need to bring the section count in the document library to under 5,000. You can do this by moving some of your notebooks out of the document library to a different storage location (such as another user or group&#8217;s OneDrive). You can also delete the notebooks that\u00a0are not required anymore.<\/p>\n<p>After\u00a0you have reduced the section count to under 5,000, rerun the tool to make sure the sections count is less than 5,000. Ideally you should keep this number below 5,000 so that you can have enough room to create new sections. If the sections count in the document library crosses 5,000 again, you will start seeing the OneNote API failures and you will need to come back here and take the same remedial steps.<\/p>\n<p><b>Case 3: Folders Count is greater 5,000<\/b><\/p>\n<p>If Folders Count is greater than 5,000, then you need to bring the folder count in the document library to under 5,000. You can do this by reorganizing the content in the document library and eliminating folders. You can also delete the folders that are not required anymore.<\/p>\n<p>After\u00a0you have reduced the folder count to under 5,000, rerun the tool to make sure the folder count is less than 5,000. Ideally you should keep this number below 5,000 so that you can have enough room to create new folders. If the folder count in the document library crosses 5,000 again, you will start seeing the OneNote API failures and you will need to come back here and take the same remedial steps.<\/p>\n<p><b>Case 4: Notebooks Count is greater than 5,000<\/b><\/p>\n<p>If Notebooks Count is greater than 5,000, then you need to bring the notebook count in the document library to under 5,000. You can do this by moving some of your notebooks out of the document library to a different storage location (such as another user or group&#8217;s OneDrive). You can also delete the notebooks that\u00a0are not required anymore.<\/p>\n<p>After\u00a0you have reduced the notebook count to under 5,000, rerun the tool to make sure the notebook count is less than 5,000. Ideally you should keep this number below 5,000 so that you can have enough room to create new notebooks. If the notebook count in the document library crosses 5,000 again, you will start seeing the OneNote API failures and you will need to come back here and take the same remedial steps.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello world! Paresh Moradiya and Sri Srinivasan, members of the OneNote API team here. We&#8217;ve heard from some of you saying that you&#8217;re running into issues when accessing SharePoint-hosted notebooks in very large document libraries. We have come up with some instructions on how you can eliminate these OneNote API failures. The problem Applications call [&hellip;]<\/p>\n","protected":false},"author":69223,"featured_media":25159,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[11],"tags":[71],"class_list":["post-1265","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-office-add-ins","tag-onenote"],"acf":[],"blog_post_summary":"<p>Hello world! Paresh Moradiya and Sri Srinivasan, members of the OneNote API team here. We&#8217;ve heard from some of you saying that you&#8217;re running into issues when accessing SharePoint-hosted notebooks in very large document libraries. We have come up with some instructions on how you can eliminate these OneNote API failures. The problem Applications call [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/1265","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/users\/69223"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/comments?post=1265"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/1265\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media\/25159"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media?parent=1265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/categories?post=1265"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/tags?post=1265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}