创建分区
本文内容
命名空间:microsoft.graph
在指定的笔记本中创建新的 onenoteSection。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
Notes.Create、Notes.ReadWrite、Notes.ReadWrite.All
委派(个人 Microsoft 帐户)
Notes.Create、Notes.ReadWrite
应用程序
Notes.ReadWrite.All
HTTP 请求
POST /me/onenote/notebooks/{id}/sections
POST /users/{id | userPrincipalName}/onenote/notebooks/{id}/sections
POST /groups/{id}/onenote/notebooks/{id}/sections
POST /sites/{id}/onenote/notebooks/{id}/sections
名称
类型
说明
Authorization
string
Bearer {token}。必需。
Content-Type
string
application/json
请求正文
在请求正文中,提供分区名称。
在同一个层次结构级别中,分区名称必须是唯一的。该名称不能超过 50 个字符,也不能包含以下字符:?*/:<>|&#''%~
响应
如果成功,此方法在响应正文中返回 响应代码和 201 Created onenoteSection 对象。
示例
请求
下面是一个请求示例。
POST https://graph.microsoft.com/v1.0/me/onenote/notebooks/{id}/sections
Content-type: application/json
{
"displayName": "Section name"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var onenoteSection = new OnenoteSection
{
DisplayName = "Section name"
};
await graphClient.Me.Onenote.Notebooks["{notebook-id}"].Sections
.Request()
.AddAsync(onenoteSection);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
const options = {
authProvider,
};
const client = Client.init(options);
const onenoteSection = {
displayName: 'Section name'
};
await client.api('/me/onenote/notebooks/{id}/sections')
.post(onenoteSection);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/onenote/notebooks/{id}/sections"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphOnenoteSection *onenoteSection = [[MSGraphOnenoteSection alloc] init];
[onenoteSection setDisplayName:@"Section name"];
NSError *error;
NSData *onenoteSectionData = [onenoteSection getSerializedDataWithError:&error];
[urlRequest setHTTPBody:onenoteSectionData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
OnenoteSection onenoteSection = new OnenoteSection();
onenoteSection.displayName = "Section name";
graphClient.me().onenote().notebooks("{id}").sections()
.buildRequest()
.post(onenoteSection);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewOnenoteSection()
displayName := "Section name"
requestBody.SetDisplayName(&displayName)
notebookId := "notebook-id"
result, err := graphClient.Me().Onenote().NotebooksById(¬ebookId).Sections().Post(requestBody)
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
Import-Module Microsoft.Graph.Notes
$params = @{
DisplayName = "Section name"
}
# A UPN can also be used as -UserId.
New-MgUserOnenoteNotebookSection -UserId $userId -NotebookId $notebookId -BodyParameter $params
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
响应
下面是一个响应示例。注意:为了简单起见,会将此处所示的响应对象截断。将从实际调用中返回所有属性。
HTTP/1.1 201 Created
Content-type: application/json
{
"isDefault": true,
"pagesUrl": "pagesUrl-value",
"displayName": "name-value",
"createdBy": {
"user": {
"id": "id-value",
"displayName": "displayName-value"
}
},
"lastModifiedBy": {
"user": {
"id": "id-value",
"displayName": "displayName-value"
}
}
}