Espace de noms : microsoft.graph.termStore
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 objet de terme .
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) |
TermStore.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. |
Requête HTTP
POST /termStore/sets/{setId}/children
POST /termStore/sets/{setId}/terms/{termId}/children
Corps de la demande
Dans le corps de la demande, fournissez une représentation JSON de l’objet de terme .
Le tableau suivant répertorie les propriétés qui sont requises lorsque vous créez le terme.
Réponse
Si elle réussit, cette méthode renvoie un 201 Created code de réponse et un objet de terme dans le corps de la réponse.
Exemples
Demande
POST https://graph.microsoft.com/beta/termStore/sets/{setId}/children
Content-Type: application/json
{
"labels": [
{
"languageTag" : "en-US",
"name" : "Car",
"isDefault" : true
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models.TermStore;
var requestBody = new Term
{
Labels = new List<LocalizedLabel>
{
new LocalizedLabel
{
LanguageTag = "en-US",
Name = "Car",
IsDefault = true,
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.TermStore.Sets["{set-id}"].Children.PostAsync(requestBody);
// 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"
graphmodelstermstore "github.com/microsoftgraph/msgraph-beta-sdk-go/models/termstore"
//other-imports
)
requestBody := graphmodelstermstore.NewTerm()
localizedLabel := graphmodelstermstore.NewLocalizedLabel()
languageTag := "en-US"
localizedLabel.SetLanguageTag(&languageTag)
name := "Car"
localizedLabel.SetName(&name)
isDefault := true
localizedLabel.SetIsDefault(&isDefault)
labels := []graphmodelstermstore.LocalizedLabelable {
localizedLabel,
}
requestBody.SetLabels(labels)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
children, err := graphClient.TermStore().Sets().BySetId("set-id").Children().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.models.termstore.Term term = new com.microsoft.graph.beta.models.termstore.Term();
LinkedList<com.microsoft.graph.beta.models.termstore.LocalizedLabel> labels = new LinkedList<com.microsoft.graph.beta.models.termstore.LocalizedLabel>();
com.microsoft.graph.beta.models.termstore.LocalizedLabel localizedLabel = new com.microsoft.graph.beta.models.termstore.LocalizedLabel();
localizedLabel.setLanguageTag("en-US");
localizedLabel.setName("Car");
localizedLabel.setIsDefault(true);
labels.add(localizedLabel);
term.setLabels(labels);
com.microsoft.graph.models.termstore.Term result = graphClient.termStore().sets().bySetId("{set-id}").children().post(term);
const options = {
authProvider,
};
const client = Client.init(options);
const term = {
labels: [
{
languageTag: 'en-US',
name: 'Car',
isDefault: true
}
]
};
await client.api('/termStore/sets/{setId}/children')
.version('beta')
.post(term);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\TermStore\Term;
use Microsoft\Graph\Beta\Generated\Models\TermStore\LocalizedLabel;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Term();
$labelsLocalizedLabel1 = new LocalizedLabel();
$labelsLocalizedLabel1->setLanguageTag('en-US');
$labelsLocalizedLabel1->setName('Car');
$labelsLocalizedLabel1->setIsDefault(true);
$labelsArray []= $labelsLocalizedLabel1;
$requestBody->setLabels($labelsArray);
$result = $graphServiceClient->termStore()->sets()->bySetId('set-id')->children()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.term_store.term import Term
from msgraph_beta.generated.models.term_store.localized_label import LocalizedLabel
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Term(
labels = [
LocalizedLabel(
language_tag = "en-US",
name = "Car",
is_default = True,
),
],
)
result = await graph_client.term_store.sets.by_set_id('set-id').children.post(request_body)
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
{
"createdDateTime": "2019-06-21T20:01:37Z",
"id": "8ed8c9ea-7052-4c1d-a4d7-b9c10bffea6f",
"labels" : [
{
"name" : "Car",
"languageTag" : "en-US",
"isDefault" : true
}
],
"lastModifiedDateTime": "2019-06-21T20:01:37Z"
}