创建 profileCardProperty
本文内容
命名空间:microsoft.graph
为组织创建新的 profileCardProperty 。 新属性由其 directoryPropertyName 属性标识。
有关如何将属性添加到组织的配置文件卡的详细信息,请参阅使用配置文件卡 API 在配置文件卡添加或删除自定义属性 。
注意
配置文件卡属性对应于 Microsoft Entra ID 中的属性。 将属性作为 profileCardProperty 添加到组织的 profileCardProperties 集合中将配置文件卡配置为显示属性值。 从集合中删除 profileCardProperty 不会从 Microsoft Entra ID 中删除属性 ;它会删除配置,以便配置文件卡不再显示属性值。
此 API 可用于以下国家级云部署 。
全局服务
美国政府 L4
美国政府 L5 (DOD)
由世纪互联运营的中国
✅
✅
✅
✅
权限
为此 API 选择标记为最低特权的权限。
只有在应用需要它时 ,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型 。 要了解有关这些权限的详细信息,请参阅 权限参考 。
权限类型
最低特权权限
更高特权权限
委派(工作或学校帐户)
PeopleSettings.ReadWrite.All
不可用。
委派(个人 Microsoft 帐户)
不支持。
不支持。
应用程序
不支持。
不支持。
注意: 对此操作使用委派权限要求已登录用户具有租户管理员或全局管理员角色。
HTTP 请求
POST /admin/people/profileCardProperties
名称
说明
Authorization
持有者 {token}。 必填。 详细了解 身份验证和授权 。
Content-Type
application/json. 必需。
注意: 若要避免导致有效负载格式错误的编码问题,请使用 Content-Type: application/json; charset=utf-8
。
请求正文
在请求正文中,提供 profileCardProperty 对象的 JSON 表示形式。
为组织创建 profileCardProperty 时,可以指定以下属性。
属性
类型
说明
注释
profileCardAnnotation 集合
管理员选择指定的任何替代标签或本地化标签。
directoryPropertyName
String
要显示在配置文件卡的目录属性的名称。
响应
如果成功,此方法在响应正文中返回响应 201 Created
代码和新的 profileCardProperty 对象。
示例
请求
以下示例显示了一个请求。
POST https://graph.microsoft.com/v1.0/admin/people/profileCardProperties
Content-type: application/json; charset=utf-8
{
"directoryPropertyName": "CustomAttribute1",
"annotations": [
{
"displayName": "Cost Center",
"localizations": [
{
"languageTag": "ru",
"displayName": "центр затрат"
}
]
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new ProfileCardProperty
{
DirectoryPropertyName = "CustomAttribute1",
Annotations = new List<ProfileCardAnnotation>
{
new ProfileCardAnnotation
{
DisplayName = "Cost Center",
Localizations = new List<DisplayNameLocalization>
{
new DisplayNameLocalization
{
LanguageTag = "ru",
DisplayName = "центр затрат",
},
},
},
},
};
// 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.PostAsync(requestBody);
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
mgc admin people profile-card-properties create --body '{\
"directoryPropertyName": "CustomAttribute1",\
"annotations": [\
{\
"displayName": "Cost Center",\
"localizations": [\
{\
"languageTag": "ru",\
"displayName": "центр затрат"\
}\
]\
}\
]\
}\
'
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewProfileCardProperty()
directoryPropertyName := "CustomAttribute1"
requestBody.SetDirectoryPropertyName(&directoryPropertyName)
profileCardAnnotation := graphmodels.NewProfileCardAnnotation()
displayName := "Cost Center"
profileCardAnnotation.SetDisplayName(&displayName)
displayNameLocalization := graphmodels.NewDisplayNameLocalization()
languageTag := "ru"
displayNameLocalization.SetLanguageTag(&languageTag)
displayName := "центр затрат"
displayNameLocalization.SetDisplayName(&displayName)
localizations := []graphmodels.DisplayNameLocalizationable {
displayNameLocalization,
}
profileCardAnnotation.SetLocalizations(localizations)
annotations := []graphmodels.ProfileCardAnnotationable {
profileCardAnnotation,
}
requestBody.SetAnnotations(annotations)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
profileCardProperties, err := graphClient.Admin().People().ProfileCardProperties().Post(context.Background(), requestBody, nil)
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
ProfileCardProperty profileCardProperty = new ProfileCardProperty();
profileCardProperty.setDirectoryPropertyName("CustomAttribute1");
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("ru");
displayNameLocalization.setDisplayName("центр затрат");
localizations.add(displayNameLocalization);
profileCardAnnotation.setLocalizations(localizations);
annotations.add(profileCardAnnotation);
profileCardProperty.setAnnotations(annotations);
ProfileCardProperty result = graphClient.admin().people().profileCardProperties().post(profileCardProperty);
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
const options = {
authProvider,
};
const client = Client.init(options);
const profileCardProperty = {
directoryPropertyName: 'CustomAttribute1',
annotations: [
{
displayName: 'Cost Center',
localizations: [
{
languageTag: 'ru',
displayName: 'центр затрат'
}
]
}
]
};
await client.api('/admin/people/profileCardProperties')
.post(profileCardProperty);
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
<?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();
$requestBody->setDirectoryPropertyName('CustomAttribute1');
$annotationsProfileCardAnnotation1 = new ProfileCardAnnotation();
$annotationsProfileCardAnnotation1->setDisplayName('Cost Center');
$localizationsDisplayNameLocalization1 = new DisplayNameLocalization();
$localizationsDisplayNameLocalization1->setLanguageTag('ru');
$localizationsDisplayNameLocalization1->setDisplayName('центр затрат');
$localizationsArray []= $localizationsDisplayNameLocalization1;
$annotationsProfileCardAnnotation1->setLocalizations($localizationsArray);
$annotationsArray []= $annotationsProfileCardAnnotation1;
$requestBody->setAnnotations($annotationsArray);
$result = $graphServiceClient->admin()->people()->profileCardProperties()->post($requestBody)->wait();
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
Import-Module Microsoft.Graph.Identity.DirectoryManagement
$params = @{
directoryPropertyName = "CustomAttribute1"
annotations = @(
@{
displayName = "Cost Center"
localizations = @(
@{
languageTag = "ru"
displayName = "центр затрат"
}
)
}
)
}
New-MgAdminPeopleProfileCardProperty -BodyParameter $params
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
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(
directory_property_name = "CustomAttribute1",
annotations = [
ProfileCardAnnotation(
display_name = "Cost Center",
localizations = [
DisplayNameLocalization(
language_tag = "ru",
display_name = "центр затрат",
),
],
),
],
)
result = await graph_client.admin.people.profile_card_properties.post(request_body)
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
响应
以下示例显示了相应的响应。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 201 Created
Content-type: application/json; charset=utf-8
{
"directoryPropertyName": "CustomAttribute1",
"annotations": [
{
"displayName": "Cost Center",
"localizations": [
{
"languageTag": "ru",
"displayName": "центр затрат"
}
]
}
]
}