使用 OneNote REST APIUse the OneNote REST API

Microsoft Graph 可让应用程序获得对个人或组织帐户中用户的 OneNote 笔记本、节和页面的授权访问权限。Microsoft Graph lets your app get authorized access to a user's OneNote notebooks, sections, and pages in a personal or organization account. 使用适当的委派或应用程序权限,你的应用程序可以访问已登录用户或租户中任何用户的 OneNote 数据。With the appropriate delegated or application permissions, your app can access the OneNote data of the signed-in user or any user in a tenant.

根 URLRoot URL

OneNote 服务根 URL 为 OneNote API 的所有调用使用以下格式。The OneNote service root URL uses the following format for all calls to the OneNote API.

https://graph.microsoft.com/{version}/{location}/onenote/ 

URL 中的 version 段表示想要使用的 Microsoft Graph 的版本:The version segment in the URL represents the version of Microsoft Graph that you want to use:

  • v1.0 用于稳定的生产代码。v1.0 is for stable production code.
  • beta 用于试用正在开发的功能。beta is to try out a feature that's in development. Beta 终结点中的特性和功能可能改变;不推荐将其用于生产代码中。Features and functionality in the beta endpoint might change; we don't recommend that you use it in your production code.

位置可以是 Office 365 或消费者版 OneDrive 上的用户笔记本,还可以是 Office 365 上的组笔记本或 SharePoint 站点托管的团队笔记本。The location can be user notebooks on Office 365 or consumer OneDrive, group notebooks, or SharePoint site-hosted team notebooks on Office 365.

OneNote API 开发堆栈

用户笔记本User notebooks

要访问消费者版 OneDrive 或 OneDrive for Business 上的个人笔记本,请使用下列 URL 之一:To access personal notebooks on consumer OneDrive or OneDrive for Business, use one of the following URLs:

https://graph.microsoft.com/{version}/me/onenote/{notebooks | sections | sectionGroups | pages} 
https://graph.microsoft.com/{version}/users/{userPrincipalName}/onenote/{notebooks | sections | sectionGroups | pages} 
https://graph.microsoft.com/{version}/users/{id}/onenote/{notebooks | sections | sectionGroups | pages} 
  • me 用于为当前用户可以访问的 OneNote 内容(拥有和共享)。me is for OneNote content that the current user can access (owned and shared).
  • users/{id} 用于指定用户已与当前用户共享的 OneNote 内容(此 URL 中)。users/{id} is for OneNote content that the specified user (in the URL) has shared with the current user. 使用 users API。Use the users API.

注意: 可以通过在 https://graph.microsoft.com/v1.0/users 上发出 GET 请求来获取用户 ID。Note: You can get user IDs by making a GET request on https://graph.microsoft.com/v1.0/users.

组笔记本Group notebooks

要访问组所有的笔记本,请使用下列服务根 URL:To access notebooks that are owned by a group, use the following service root URL:

https://graph.microsoft.com/{version}/groups/{id}/onenote/{notebooks | sections | sectionGroups | pages} 

SharePoint 网站笔记本SharePoint site notebooks

要访问 SharePoint 团队网站拥有的笔记本,请使用下列服务根 URL:To access notebooks that are owned by a SharePoint team site, use the following service root URL:

https://graph.microsoft.com/{version}/sites/{id}/onenote/{notebooks | sections | sectionGroups | pages}