Espace de noms: microsoft.graph
Importante
Les API sous la version /beta
dans Microsoft Graph sont susceptibles d’être modifiées. L’utilisation de ces API dans des applications de production n’est pas prise en charge. Pour déterminer si une API est disponible dans v1.0, utilisez le sélecteur Version .
Créez un profilCardProperty pour un organization. La nouvelle propriété est identifiée par sa propriété directoryPropertyName .
Pour plus d’informations sur l’ajout de propriétés au carte de profil pour un organization, consultez Ajouter ou supprimer des attributs personnalisés sur un profil carte à l’aide de l’API de carte de profil.
Remarque
Les propriétés de carte de profil correspondent aux attributs dans Microsoft Entra ID. L’ajout d’un attribut en tant que profileCardProperty à la collection profileCardProperties pour un organization configure les cartes de profil pour afficher la valeur de l’attribut. La suppression de profileCardProperty de la collection ne supprime pas l’attribut de Microsoft Entra ID ; elle supprime la configuration afin que les cartes de profil n’affichent plus la valeur de l’attribut.
Cette API est disponible dans les déploiements de cloud national suivants.
Service global |
Gouvernement des États-Unis L4 |
Us Government L5 (DOD) |
Chine gérée par 21Vianet |
✅ |
✅ |
✅ |
✅ |
Autorisations
Choisissez l’autorisation ou les autorisations marquées comme moins privilégiées pour cette API. Utilisez une autorisation ou des autorisations privilégiées plus élevées uniquement si votre application en a besoin. Pour plus d’informations sur les autorisations déléguées et d’application, consultez Types d’autorisations. Pour en savoir plus sur ces autorisations, consultez les informations de référence sur les autorisations.
Type d’autorisation |
Autorisations avec privilèges minimum |
Autorisations privilégiées plus élevées |
Déléguée (compte professionnel ou scolaire) |
PeopleSettings.ReadWrite.All |
Non disponible. |
Déléguée (compte Microsoft personnel) |
Non prise en charge. |
Non prise en charge. |
Application |
Non prise en charge. |
Non prise en charge. |
Note: L’utilisation d’autorisations déléguées pour cette opération nécessite que l’utilisateur connecté ait un rôle Administrateur de locataire ou Administrateur Personnes.
Requête HTTP
POST /admin/people/profileCardProperties
Remarque : le chemin d’accès /organization/{organizationId}/settings
est obsolète. À l’avenir, utilisez le chemin d’accès /admin/people
.
Note: Pour éviter les problèmes d’encodage qui malforment la charge utile, utilisez Content-Type: application/json; charset=utf-8
.
Corps de la demande
Dans le corps de la demande, fournissez une représentation JSON d’un objet profileCardProperty .
Vous pouvez spécifier les propriétés suivantes lorsque vous créez un profileCardProperty pour un organization.
Propriété |
Type |
Description |
Annotations |
collection profileCardAnnotation |
Toutes les étiquettes alternatives ou localisées qu’un administrateur a choisi de spécifier. |
directoryPropertyName |
String |
Nom de la propriété de répertoire destinée à apparaître sur le profil carte. |
Réponse
Si elle réussit, cette méthode renvoie un 201 Created
code de réponse et un nouvel objet profileCardProperty dans le corps de la réponse.
Exemples
Demande
L’exemple suivant illustre une demande.
POST https://graph.microsoft.com/beta/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.Beta.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);
mgc-beta admin people profile-card-properties create --body '{\
"directoryPropertyName": "CustomAttribute1",\
"annotations": [\
{\
"displayName": "Cost Center",\
"localizations": [\
{\
"languageTag": "ru",\
"displayName": "центр затрат"\
}\
]\
}\
]\
}\
'
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-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)
// 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);
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')
.version('beta')
.post(profileCardProperty);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\ProfileCardProperty;
use Microsoft\Graph\Beta\Generated\Models\ProfileCardAnnotation;
use Microsoft\Graph\Beta\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();
Import-Module Microsoft.Graph.Beta.Identity.DirectoryManagement
$params = @{
directoryPropertyName = "CustomAttribute1"
annotations = @(
@{
displayName = "Cost Center"
localizations = @(
@{
languageTag = "ru"
displayName = "центр затрат"
}
)
}
)
}
New-MgBetaAdminPeopleProfileCardProperty -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.profile_card_property import ProfileCardProperty
from msgraph_beta.generated.models.profile_card_annotation import ProfileCardAnnotation
from msgraph_beta.generated.models.display_name_localization import DisplayNameLocalization
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
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)
Réponse
L’exemple suivant illustre la réponse.
Remarque : l’objet de réponse affiché ci-après peut être raccourci pour plus de lisibilité.
HTTP/1.1 201 Created
Content-type: application/json; charset=utf-8
{
"directoryPropertyName": "CustomAttribute1",
"annotations": [
{
"displayName": "Cost Center",
"localizations": [
{
"languageTag": "ru",
"displayName": "центр затрат"
}
]
}
]
}