命名空间:microsoft.graph
重要
Microsoft Graph /beta 版本下的 API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
更新用户团队合作中分区的属性。 对于系统定义的节,只能更新 sortType 属性。
此 API 可用于以下国家级云部署。
| 全局服务 |
美国政府 L4 |
美国政府 L5 (DOD) |
由世纪互联运营的中国 |
| ✅ |
❌ |
❌ |
❌ |
权限
为此 API 选择标记为最低特权的权限。
只有在应用需要它时,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考。
| 权限类型 |
最低特权权限 |
更高特权权限 |
| 委派(工作或学校帐户) |
TeamworkSection.ReadWrite |
不可用。 |
| 委派(个人 Microsoft 帐户) |
不支持。 |
不支持。 |
| 应用程序 |
TeamworkSection.ReadWrite.All |
Teamwork.Migrate.All |
HTTP 请求
PATCH /users/{user-id}/teamwork/sections/{teamworkSection-id}
| 标头 |
值 |
| Authorization |
持有者 {token}。 必填。 详细了解 身份验证和授权。 |
| Content-Type |
application/json. 必需。 |
| If-Match |
列出节时返回的 @microsoft.graph.sectionsVersion 注释的值,或以前检索到的任何节中的 @odata.etag 值。 对于乐观并发控制是必需的。 |
请求正文
在请求正文中,仅提供要更新的属性的 JSON 表示形式。 可更新以下属性。
| 属性 |
类型 |
说明 |
| displayIcon |
sectionDisplayIcon |
为分区显示的图标。 |
| displayName |
String |
部分的显示名称。 最大长度为 50 个字符。 显示名称区分大小写,并且必须在用户的分区中唯一。 无法使用系统定义的保留名称 (RecentChats、QuickViews、TeamsAndChannels、 MutedChatsMeetingChatsEngageCommunities 、) 。 |
| isExpanded |
布尔值 |
指示是否在用户界面中展开节。 |
| sortType |
sectionSortType |
节中项的排序顺序。 可能的值包括 mostRecent、unreadThenMostRecent、nameAlphabetical、userDefinedCustomOrder、unknownFutureValue。 |
重要
有效的 sortType 值取决于节类型:
-
用户定义的部分:
mostRecent、 unreadThenMostRecent和 userDefinedCustomOrder 有效。 不支持 nameAlphabetical。
-
系统定义的节:有效值取决于特定节。 例如, Teams 和 频道 部分支持
nameAlphabetical,但 “最近聊天 ”和“ MutedChat” 部分不支持。 当属性 isHierarchicalViewEnabled 设置为 true时,只有 nameAlphabetical 有效。
响应
如果成功,此方法在响应正文中返回响应 200 OK 代码和更新的 teamworkSection 对象。
注意
响应包括更新 的 @odata.etag 值。 使用此值作为 If-Match 任何后续突变操作的标头。
可能存在以下错误。
| 响应代码 |
邮件 |
400 Bad Request |
必须至少提供一个属性才能进行更新。 |
400 Bad Request |
“displayName”属性不得为空或空格,或者不能超过 50 个字符。 |
400 Bad Request |
属性“{propertyName}”是只读的或不可更新的。 只能更新 displayName、 displayIcon、 isExpanded 和 sortType 。 |
400 Bad Request |
指定的排序类型对于本部分无效。 有关详细信息,请参阅 请求正文 部分。 |
403 Forbidden |
此部分是系统生成的,无法修改。 只能在系统定义的节上更新 sortType 属性。 |
404 Not Found |
找不到指定的节。 |
409 Conflict |
具有此显示名称的节已存在。 当请求的 displayName 与现有的用户定义节或保留的系统定义节名称匹配时返回。 比较区分大小写。 |
412 Precondition Failed |
标头 If-Match 值与当前节层次结构版本不匹配。 再次列出节以检索当前 @microsoft.graph.sectionsVersion 批注并重试。 |
428 Precondition Required |
If-Match此操作需要 标头。 |
示例
示例 1:更新分区的显示名称
以下示例演示如何更新 teamworkSection 对象的显示名称。
请求
以下示例显示了一个请求。
PATCH https://graph.microsoft.com/beta/users/10f8c3a6-3e2a-4e8b-9c7d-5a4b6c8d9e0f/teamwork/sections/a1b2c3d4-e5f6-7890-abcd-ef1234567890
Content-type: application/json
If-Match: "1742515200"
{
"displayName": "Important Conversations"
}
// 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 = "Important Conversations",
};
// 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["{teamworkSection-id}"].PatchAsync(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.ItemTeamworkSectionsItemRequestBuilderPatchRequestConfiguration{
Headers: headers,
}
requestBody := graphmodels.NewTeamworkSection()
displayName := "Important Conversations"
requestBody.SetDisplayName(&displayName)
// 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().ByTeamworkSectionId("teamworkSection-id").Patch(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("Important Conversations");
TeamworkSection result = graphClient.users().byUserId("{user-id}").teamwork().sections().byTeamworkSectionId("{teamworkSection-id}").patch(teamworkSection, requestConfiguration -> {
requestConfiguration.headers.add("If-Match", "\"1742515200\"");
});
const options = {
authProvider,
};
const client = Client.init(options);
const teamworkSection = {
displayName: 'Important Conversations'
};
await client.api('/users/10f8c3a6-3e2a-4e8b-9c7d-5a4b6c8d9e0f/teamwork/sections/a1b2c3d4-e5f6-7890-abcd-ef1234567890')
.version('beta')
.update(teamworkSection);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\Teamwork\Sections\Item\TeamworkSectionItemRequestBuilderPatchRequestConfiguration;
use Microsoft\Graph\Beta\Generated\Models\TeamworkSection;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new TeamworkSection();
$requestBody->setDisplayName('Important Conversations');
$requestConfiguration = new TeamworkSectionItemRequestBuilderPatchRequestConfiguration();
$headers = [
'If-Match' => '"1742515200"',
];
$requestConfiguration->headers = $headers;
$result = $graphServiceClient->users()->byUserId('user-id')->teamwork()->sections()->byTeamworkSectionId('teamworkSection-id')->patch($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.item.teamwork_section_item_request_builder import TeamworkSectionItemRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
from msgraph_beta.generated.models.teamwork_section import TeamworkSection
# 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 = "Important Conversations",
)
request_configuration = RequestConfiguration()
request_configuration.headers.add("If-Match", "\"1742515200\"")
result = await graph_client.users.by_user_id('user-id').teamwork.sections.by_teamwork_section_id('teamworkSection-id').patch(request_body, request_configuration = request_configuration)
响应
以下示例显示了相应的响应。
注意:为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.type": "#microsoft.graph.teamworkSection",
"@odata.etag": "\"1742515210\"",
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"displayName": "Important Conversations",
"displayIcon": {
"iconType": "⭐",
"displayName": "Star",
"contentUrl": null,
"skinTone": null
},
"sectionType": "userDefined",
"sortType": "mostRecent",
"isExpanded": true,
"isHierarchicalViewEnabled": false,
"createdDateTime": "2025-01-15T10:30:00Z",
"lastModifiedDateTime": "2026-03-08T09:15:00Z"
}
示例 2:更新节的排序顺序
以下示例演示如何更新 teamworkSection 对象的排序顺序。
请求
以下示例显示了一个请求。
PATCH https://graph.microsoft.com/beta/users/10f8c3a6-3e2a-4e8b-9c7d-5a4b6c8d9e0f/teamwork/sections/a1b2c3d4-e5f6-7890-abcd-ef1234567890
Content-type: application/json
If-Match: "1742515210"
{
"sortType": "unreadThenMostRecent"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new TeamworkSection
{
SortType = SectionSortType.UnreadThenMostRecent,
};
// 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["{teamworkSection-id}"].PatchAsync(requestBody, (requestConfiguration) =>
{
requestConfiguration.Headers.Add("If-Match", "\"1742515210\"");
});
// 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", "\"1742515210\"")
configuration := &graphusers.ItemTeamworkSectionsItemRequestBuilderPatchRequestConfiguration{
Headers: headers,
}
requestBody := graphmodels.NewTeamworkSection()
sortType := graphmodels.UNREADTHENMOSTRECENT_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().ByTeamworkSectionId("teamworkSection-id").Patch(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.setSortType(SectionSortType.UnreadThenMostRecent);
TeamworkSection result = graphClient.users().byUserId("{user-id}").teamwork().sections().byTeamworkSectionId("{teamworkSection-id}").patch(teamworkSection, requestConfiguration -> {
requestConfiguration.headers.add("If-Match", "\"1742515210\"");
});
const options = {
authProvider,
};
const client = Client.init(options);
const teamworkSection = {
sortType: 'unreadThenMostRecent'
};
await client.api('/users/10f8c3a6-3e2a-4e8b-9c7d-5a4b6c8d9e0f/teamwork/sections/a1b2c3d4-e5f6-7890-abcd-ef1234567890')
.version('beta')
.update(teamworkSection);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\Teamwork\Sections\Item\TeamworkSectionItemRequestBuilderPatchRequestConfiguration;
use Microsoft\Graph\Beta\Generated\Models\TeamworkSection;
use Microsoft\Graph\Beta\Generated\Models\SectionSortType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new TeamworkSection();
$requestBody->setSortType(new SectionSortType('unreadThenMostRecent'));
$requestConfiguration = new TeamworkSectionItemRequestBuilderPatchRequestConfiguration();
$headers = [
'If-Match' => '"1742515210"',
];
$requestConfiguration->headers = $headers;
$result = $graphServiceClient->users()->byUserId('user-id')->teamwork()->sections()->byTeamworkSectionId('teamworkSection-id')->patch($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.item.teamwork_section_item_request_builder import TeamworkSectionItemRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
from msgraph_beta.generated.models.teamwork_section import TeamworkSection
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(
sort_type = SectionSortType.UnreadThenMostRecent,
)
request_configuration = RequestConfiguration()
request_configuration.headers.add("If-Match", "\"1742515210\"")
result = await graph_client.users.by_user_id('user-id').teamwork.sections.by_teamwork_section_id('teamworkSection-id').patch(request_body, request_configuration = request_configuration)
响应
以下示例显示了相应的响应。
注意:为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.type": "#microsoft.graph.teamworkSection",
"@odata.etag": "\"1742515220\"",
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"displayName": "Important Conversations",
"displayIcon": {
"iconType": "⭐",
"displayName": "Star",
"contentUrl": null,
"skinTone": null
},
"sectionType": "userDefined",
"sortType": "unreadThenMostRecent",
"isExpanded": true,
"isHierarchicalViewEnabled": false,
"createdDateTime": "2025-01-15T10:30:00Z",
"lastModifiedDateTime": "2026-03-08T09:20:00Z"
}