命名空间:microsoft.graph
重要
Microsoft Graph /beta 版本下的 API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
在用户的团队合作中创建新分区。
此 API 可用于以下国家级云部署。
| 全局服务 |
美国政府 L4 |
美国政府 L5 (DOD) |
由世纪互联运营的中国 |
| ✅ |
❌ |
❌ |
❌ |
权限
为此 API 选择标记为最低特权的权限。
只有在应用需要它时,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考。
| 权限类型 |
最低特权权限 |
更高特权权限 |
| 委派(工作或学校帐户) |
TeamworkSection.ReadWrite |
不可用。 |
| 委派(个人 Microsoft 帐户) |
不支持。 |
不支持。 |
| 应用程序 |
TeamworkSection.ReadWrite.All |
Teamwork.Migrate.All |
HTTP 请求
POST /users/{user-id}/teamwork/sections
| 标头 |
值 |
| Authorization |
持有者 {token}。 必填。 详细了解 身份验证和授权。 |
| Content-Type |
application/json. 必需。 |
| If-Match |
列出节时返回的 @microsoft.graph.sectionsVersion 注释的值,或以前检索到的任何节中的 @odata.etag 值。 对于乐观并发控制是必需的。 |
请求正文
在请求正文中,提供 teamworkSection 对象的 JSON 表示形式。
下表列出了在创建 teamworkSection 时可以设置的属性。
| 属性 |
类型 |
说明 |
| displayIcon |
sectionDisplayIcon |
为分区显示的图标。 可选。 无法设置图标的 skinTone 属性,并且派生自用户设置。 |
| displayName |
String |
部分的显示名称。 必填。 最大长度为 50 个字符。 显示名称区分大小写,并且必须在用户的分区中唯一。 以下名称是为系统定义的部分保留的,不能使用:RecentChats、、QuickViews、TeamsAndChannels、MutedChatsMeetingChats、。 EngageCommunities |
| isExpanded |
布尔值 |
指示是否在用户界面中展开节。 可选。 默认值为 true。 |
| sortType |
sectionSortType |
节中项的排序顺序。 可选。 默认值为 userDefinedCustomOrder。 用户定义的节的有效值为:mostRecent、unreadThenMostRecent、、userDefinedCustomOrderunknownFutureValue。 该 nameAlphabetical 成员对用户定义的节无效。 |
响应
如果成功,此方法在 201 Created 响应正文中返回响应代码和 teamworkSection 对象。
注意
响应包括更新 的 @odata.etag 值。 使用此值作为 If-Match 任何后续突变操作的标头。
可能存在以下错误。
| 响应代码 |
邮件 |
400 Bad Request |
“displayName”属性是必需的,并且不能为空。 |
400 Bad Request |
“displayName”属性不能超过 50 个字符。 |
400 Bad Request |
节显示名称包含无效字符或格式。 |
400 Bad Request |
“id”、“createdDateTime”、“lastModifiedDateTime”、“sectionType”或“isHierarchicalViewEnabled”属性是只读的,在创建节时不得提供。 |
400 Bad Request |
不支持“displayIcon.contentUrl”属性,或者“displayIcon.displayName”或“displayIcon.skinTone”属性是只读的,不得提供。 |
400 Bad Request |
已达到最大节数。 |
409 Conflict |
具有此显示名称的节已存在。 当请求的 displayName 与现有的用户定义的节或保留的系统定义节名之一 (RecentChats、QuickViews、、 MeetingChatsTeamsAndChannelsMutedChatsEngageCommunities) 匹配时返回。 比较区分大小写。 |
412 Precondition Failed |
标头 If-Match 值与当前节层次结构版本不匹配。 再次列出节以检索当前 @microsoft.graph.sectionsVersion 批注并重试。 |
428 Precondition Required |
If-Match此操作需要 标头。 |
示例
请求
以下示例显示了一个请求。
POST https://graph.microsoft.com/beta/users/10f8c3a6-3e2a-4e8b-9c7d-5a4b6c8d9e0f/teamwork/sections
Content-type: application/json
If-Match: "1742515200"
{
"displayName": "Project Alpha",
"displayIcon": {
"iconType": "🚀"
},
"sortType": "mostRecent"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new TeamworkSection
{
DisplayName = "Project Alpha",
DisplayIcon = new SectionDisplayIcon
{
IconType = "🚀",
},
SortType = SectionSortType.MostRecent,
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Users["{user-id}"].Teamwork.Sections.PostAsync(requestBody, (requestConfiguration) =>
{
requestConfiguration.Headers.Add("If-Match", "\"1742515200\"");
});
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
abstractions "github.com/microsoft/kiota-abstractions-go"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
graphusers "github.com/microsoftgraph/msgraph-beta-sdk-go/users"
//other-imports
)
headers := abstractions.NewRequestHeaders()
headers.Add("If-Match", "\"1742515200\"")
configuration := &graphusers.ItemTeamworkSectionsRequestBuilderPostRequestConfiguration{
Headers: headers,
}
requestBody := graphmodels.NewTeamworkSection()
displayName := "Project Alpha"
requestBody.SetDisplayName(&displayName)
displayIcon := graphmodels.NewSectionDisplayIcon()
iconType := "🚀"
displayIcon.SetIconType(&iconType)
requestBody.SetDisplayIcon(displayIcon)
sortType := graphmodels.MOSTRECENT_SECTIONSORTTYPE
requestBody.SetSortType(&sortType)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
sections, err := graphClient.Users().ByUserId("user-id").Teamwork().Sections().Post(context.Background(), requestBody, configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
TeamworkSection teamworkSection = new TeamworkSection();
teamworkSection.setDisplayName("Project Alpha");
SectionDisplayIcon displayIcon = new SectionDisplayIcon();
displayIcon.setIconType("🚀");
teamworkSection.setDisplayIcon(displayIcon);
teamworkSection.setSortType(SectionSortType.MostRecent);
TeamworkSection result = graphClient.users().byUserId("{user-id}").teamwork().sections().post(teamworkSection, requestConfiguration -> {
requestConfiguration.headers.add("If-Match", "\"1742515200\"");
});
const options = {
authProvider,
};
const client = Client.init(options);
const teamworkSection = {
displayName: 'Project Alpha',
displayIcon: {
iconType: '🚀'
},
sortType: 'mostRecent'
};
await client.api('/users/10f8c3a6-3e2a-4e8b-9c7d-5a4b6c8d9e0f/teamwork/sections')
.version('beta')
.post(teamworkSection);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\Teamwork\Sections\SectionsRequestBuilderPostRequestConfiguration;
use Microsoft\Graph\Beta\Generated\Models\TeamworkSection;
use Microsoft\Graph\Beta\Generated\Models\SectionDisplayIcon;
use Microsoft\Graph\Beta\Generated\Models\SectionSortType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new TeamworkSection();
$requestBody->setDisplayName('Project Alpha');
$displayIcon = new SectionDisplayIcon();
$displayIcon->setIconType('🚀');
$requestBody->setDisplayIcon($displayIcon);
$requestBody->setSortType(new SectionSortType('mostRecent'));
$requestConfiguration = new SectionsRequestBuilderPostRequestConfiguration();
$headers = [
'If-Match' => '"1742515200"',
];
$requestConfiguration->headers = $headers;
$result = $graphServiceClient->users()->byUserId('user-id')->teamwork()->sections()->post($requestBody, $requestConfiguration)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.users.item.teamwork.sections.sections_request_builder import SectionsRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
from msgraph_beta.generated.models.teamwork_section import TeamworkSection
from msgraph_beta.generated.models.section_display_icon import SectionDisplayIcon
from msgraph_beta.generated.models.section_sort_type import SectionSortType
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = TeamworkSection(
display_name = "Project Alpha",
display_icon = SectionDisplayIcon(
icon_type = "🚀",
),
sort_type = SectionSortType.MostRecent,
)
request_configuration = RequestConfiguration()
request_configuration.headers.add("If-Match", "\"1742515200\"")
result = await graph_client.users.by_user_id('user-id').teamwork.sections.post(request_body, request_configuration = request_configuration)
响应
以下示例显示了相应的响应。
注意:为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 201 Created
Content-type: application/json
Location: https://graph.microsoft.com/beta/users/10f8c3a6-3e2a-4e8b-9c7d-5a4b6c8d9e0f/teamwork/sections/c3d4e5f6-a7b8-9012-cdef-123456789012
{
"@odata.type": "#microsoft.graph.teamworkSection",
"@odata.etag": "\"1742515210\"",
"id": "c3d4e5f6-a7b8-9012-cdef-123456789012",
"displayName": "Project Alpha",
"displayIcon": {
"iconType": "🚀",
"displayName": "Rocket",
"contentUrl": null,
"skinTone": null
},
"sectionType": "userDefined",
"sortType": "mostRecent",
"isExpanded": true,
"isHierarchicalViewEnabled": false,
"createdDateTime": "2026-03-08T10:00:00Z",
"lastModifiedDateTime": "2026-03-08T10:00:00Z"
}