简体   繁体   中英

OneNote on SharePoint REST API

The OneNote team recently published a blog post in which they explain how to access data from OneNote notebooks that are stored on SharePoint ('site-hosted notebooks', as they refer to them).

I'm trying to use the API as they describe it, but I'm unable to get it to work. Specifically, the first step is to find out my site collections and site ID using the following API call:

https://www.onenote.com/api/beta/myorganization/siteCollections/FromUrl(url='{full-path-to-SharePoint-site}')

It seems to fail no matter what I do: I tried to put the full path to my SharePoint site with and without 'http://' or 'https://', tried to write my organization name in various ways (with '-my' at the end, and without it), and probably a few other combinations as well - it just doesn't work. I keep getting error 400 / bad request.

Any help would be greatly appreciated.

So ... I had a fairly long correspondence with the guys from Microsoft, and here's what I learned:

  • If you're using a browser or a browser plug-in to test some of your REST APIs calls, it's not enough to be logged-in as the relevant user. This works for SharePoint and other Office 365 APIs, but not for this OneNote API. You must send "Authorization: Bearer ... " in the request headers.
  • Probably my stupid mistake, but 'myorganization' in the URL https://www.onenote.com/api/beta/myorganization/siteCollections/FromUrl(url='{full-path-to-SharePoint-site}') is not the name of your organization / domain: it's the literal string 'myorganization'.
  • Finally, the 'full-path-to-sharepoint-site' should point to https://xyz.sharepoint.com and not to https://xyz-my.sharepoint.com .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM