Update profileCardProperty
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph /beta
版本下的 API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
更新 profileCardProperty 对象的属性,由其 directoryPropertyName 属性标识。
此 API 可用于以下国家级云部署 。
全局服务
美国政府 L4
美国政府 L5 (DOD)
由世纪互联运营的中国
✅
✅
✅
✅
权限
为此 API 选择标记为最低特权的权限。 只有在应用需要它时 ,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型 。 要了解有关这些权限的详细信息,请参阅 权限参考 。
权限类型
最低特权权限
更高特权权限
委派(工作或学校帐户)
PeopleSettings.ReadWrite.All
不可用。
委派(个人 Microsoft 帐户)
不支持。
不支持。
应用程序
不支持。
不支持。
注意: 对此操作使用委派权限要求已登录用户具有租户管理员或全局管理员角色。
HTTP 请求
PATCH /admin/people/profileCardProperties/{id}
注意: /organization/{organizationId}/settings
路径已弃用。 今后将使用 /admin/people
路径。
名称
说明
Authorization
持有者 {token}。 必填。 详细了解 身份验证和授权 。
Content-Type
application/json. 必需。
注意: 若要避免导致有效负载格式错误的编码问题,请使用 Content-Type: application/json; charset=utf-8
。
请求正文
在请求正文中,仅 提供应更新的属性的值。 请求正文中未包含的现有属性会保留其以前的值,或者根据对其他属性值的更改重新计算。
下表指定可更新的属性。
属性
类型
说明
注释
profileCardAnnotation 集合
管理员选择指定的任何替代标签或本地化标签。
directoryPropertyName
String
要显示在配置文件卡的目录属性的名称。
响应
如果成功,此方法在响应正文中返回响应 200 OK
代码和更新的 profileCardProperty 对象。
示例
请求
以下示例为区域no
设置 添加本地化标签Kostnadssenter
。
PATCH https://graph.microsoft.com/beta/admin/people/profileCardProperties/CustomAttribute1
Content-type: application/json; charset=utf-8
{
"annotations": [
{
"displayName": "Cost Center",
"localizations": [
{
"languageTag": "no",
"displayName": "Kostnadssenter"
}
]
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new ProfileCardProperty
{
Annotations = new List<ProfileCardAnnotation>
{
new ProfileCardAnnotation
{
DisplayName = "Cost Center",
Localizations = new List<DisplayNameLocalization>
{
new DisplayNameLocalization
{
LanguageTag = "no",
DisplayName = "Kostnadssenter",
},
},
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Admin.People.ProfileCardProperties["{profileCardProperty-id}"].PatchAsync(requestBody);
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc-beta admin people profile-card-properties patch --profile-card-property-id {profileCardProperty-id} --body '{\
"annotations": [\
{\
"displayName": "Cost Center",\
"localizations": [\
{\
"languageTag": "no",\
"displayName": "Kostnadssenter"\
}\
]\
}\
]\
}\
'
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
requestBody := graphmodels.NewProfileCardProperty()
profileCardAnnotation := graphmodels.NewProfileCardAnnotation()
displayName := "Cost Center"
profileCardAnnotation.SetDisplayName(&displayName)
displayNameLocalization := graphmodels.NewDisplayNameLocalization()
languageTag := "no"
displayNameLocalization.SetLanguageTag(&languageTag)
displayName := "Kostnadssenter"
displayNameLocalization.SetDisplayName(&displayName)
localizations := []graphmodels.DisplayNameLocalizationable {
displayNameLocalization,
}
profileCardAnnotation.SetLocalizations(localizations)
annotations := []graphmodels.ProfileCardAnnotationable {
profileCardAnnotation,
}
requestBody.SetAnnotations(annotations)
profileCardProperties, err := graphClient.Admin().People().ProfileCardProperties().ByProfileCardPropertyId("profileCardProperty-id").Patch(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
ProfileCardProperty profileCardProperty = new ProfileCardProperty();
LinkedList<ProfileCardAnnotation> annotations = new LinkedList<ProfileCardAnnotation>();
ProfileCardAnnotation profileCardAnnotation = new ProfileCardAnnotation();
profileCardAnnotation.setDisplayName("Cost Center");
LinkedList<DisplayNameLocalization> localizations = new LinkedList<DisplayNameLocalization>();
DisplayNameLocalization displayNameLocalization = new DisplayNameLocalization();
displayNameLocalization.setLanguageTag("no");
displayNameLocalization.setDisplayName("Kostnadssenter");
localizations.add(displayNameLocalization);
profileCardAnnotation.setLocalizations(localizations);
annotations.add(profileCardAnnotation);
profileCardProperty.setAnnotations(annotations);
ProfileCardProperty result = graphClient.admin().people().profileCardProperties().byProfileCardPropertyId("{profileCardProperty-id}").patch(profileCardProperty);
const options = {
authProvider,
};
const client = Client.init(options);
const profileCardProperty = {
annotations: [
{
displayName: 'Cost Center',
localizations: [
{
languageTag: 'no',
displayName: 'Kostnadssenter'
}
]
}
]
};
await client.api('/admin/people/profileCardProperties/CustomAttribute1')
.version('beta')
.update(profileCardProperty);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\ProfileCardProperty;
use Microsoft\Graph\Generated\Models\ProfileCardAnnotation;
use Microsoft\Graph\Generated\Models\DisplayNameLocalization;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new ProfileCardProperty();
$annotationsProfileCardAnnotation1 = new ProfileCardAnnotation();
$annotationsProfileCardAnnotation1->setDisplayName('Cost Center');
$localizationsDisplayNameLocalization1 = new DisplayNameLocalization();
$localizationsDisplayNameLocalization1->setLanguageTag('no');
$localizationsDisplayNameLocalization1->setDisplayName('Kostnadssenter');
$localizationsArray []= $localizationsDisplayNameLocalization1;
$annotationsProfileCardAnnotation1->setLocalizations($localizationsArray);
$annotationsArray []= $annotationsProfileCardAnnotation1;
$requestBody->setAnnotations($annotationsArray);
$result = $graphServiceClient->admin()->people()->profileCardProperties()->byProfileCardPropertyId('profileCardProperty-id')->patch($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Identity.DirectoryManagement
$params = @{
annotations = @(
@{
displayName = "Cost Center"
localizations = @(
@{
languageTag = "no"
displayName = "Kostnadssenter"
}
)
}
)
}
Update-MgBetaAdminPeopleProfileCardProperty -ProfileCardPropertyId $profileCardPropertyId -BodyParameter $params
from msgraph import GraphServiceClient
from msgraph.generated.models.profile_card_property import ProfileCardProperty
from msgraph.generated.models.profile_card_annotation import ProfileCardAnnotation
from msgraph.generated.models.display_name_localization import DisplayNameLocalization
graph_client = GraphServiceClient(credentials, scopes)
request_body = ProfileCardProperty(
annotations = [
ProfileCardAnnotation(
display_name = "Cost Center",
localizations = [
DisplayNameLocalization(
language_tag = "no",
display_name = "Kostnadssenter",
),
],
),
],
)
result = await graph_client.admin.people.profile_card_properties.by_profile_card_property_id('profileCardProperty-id').patch(request_body)
响应
以下示例显示了相应的响应。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json; charset=utf-8
{
"directoryPropertyName": "CustomAttribute1",
"annotations": [
{
"displayName": "Cost Center",
"localizations": [
{
"languageTag": "no",
"displayName": "Kostnadssenter"
}
]
}
]
}