创建页面

命名空间:microsoft.graph

在指定分区中新建页面

此 API 可用于以下国家级云部署

全局服务 美国政府 L4 美国政府 L5 (DOD) 由世纪互联运营的中国

权限

为此 API 选择标记为最低特权的权限。 只有在应用需要它时,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考

权限类型 最低特权权限 更高特权权限
委派(工作或学校帐户) Notes.Create Notes.ReadWrite、Notes.ReadWrite.All
委派(个人 Microsoft 帐户) Notes.Create Notes.ReadWrite
应用程序 Notes.ReadWrite.All 不可用。

HTTP 请求

POST /me/onenote/sections/{id}/pages
POST /users/{id | userPrincipalName}/onenote/sections/{id}/pages
POST /groups/{id}/onenote/sections/{id}/pages
POST /sites/{id}/onenote/sections/{id}/pages

请求标头

名称 类型 说明
Authorization string 持有者 {token}。 必填。
Content-Type 字符串 text/htmlapplication/xhtml+xml 用于 HTML 内容,包括多部分请求所需的“演示文稿”部分。 多部分请求使用 multipart/form-data; boundary=your-boundary 内容类型。

请求正文

在请求正文中,提供页面的 HTML 内容。

正文可以包含直接放置在请求正文中的 HTML,也可以包含多部分消息格式,如示例中所示。 如果要发送二进制数据,则必须发送多部分请求。

响应

如果成功,此方法在响应正文中返回 201 Created 响应代码和新的 page 对象。

示例

请求

以下示例显示了一个请求。

POST https://graph.microsoft.com/v1.0/me/onenote/sections/{id}/pages
Content-type: multipart/form-data; boundary=MyPartBoundary198374

--MyPartBoundary198374
Content-Disposition:form-data; name="Presentation"
Content-Type:text/html

<!DOCTYPE html>
<html>
  <head>
    <title>A page with <i>rendered</i> images and an <b>attached</b> file</title>
    <meta name="created" content="2015-07-22T09:00:00-08:00" />
  </head>
  <body>
    <p>Here's an image from an online source:</p>
    <img src="https://..." alt="an image on the page" width="500" />
    <p>Here's an image uploaded as binary data:</p>
    <img src="name:imageBlock1" alt="an image on the page" width="300" />
    <p>Here's a file attachment:</p>
    <object data-attachment="FileName.pdf" data="name:fileBlock1" type="application/pdf" />
  </body>
</html>

--MyPartBoundary198374
Content-Disposition:form-data; name="imageBlock1"
Content-Type:image/jpeg

... binary image data ...

--MyPartBoundary198374
Content-Disposition:form-data; name="fileBlock1"
Content-Type:application/pdf

... binary file data ...

--MyPartBoundary198374--
响应

以下示例显示了相应的响应。 注意:为简洁起见,此处显示的响应对象被截断。 将从实际调用中返回所有属性。

HTTP/1.1 200 OK
Content-type: application/json

{
  "title": "title-value",
  "createdByAppId": "createdByAppId-value",
  "links": {
    "oneNoteClientUrl": {
      "href": "href-value"
    },
    "oneNoteWebUrl": {
      "href": "href-value"
    }
  },
  "contentUrl": "contentUrl-value",
  "lastModifiedDateTime": "2016-10-19T10:37:00Z"
}