Dans le corps de la demande, fournissez une représentation JSON d’un objet de contrat .
Le tableau suivant indique les propriétés requises lorsque vous créez un contrat.
Propriété
Type
Description
displayName
Chaîne
Nom d’affichage du contrat.
isViewingBeforeAcceptanceRequired
Valeur booléenne
Indique si l’utilisateur doit développer et afficher le contrat avant d’accepter.
fileName
Chaîne
Nom du fichier d’accord (par exemple, TOU.pdf).
isDefault
Valeur booléenne
Indique s’il s’agit du fichier de contrat par défaut si la langue correspond à la préférence du client. Si aucun des fichiers n’est marqué comme fichier par défaut, le premier est traité comme étant par défaut.
language
Chaîne
Langue du fichier de contrat au format « languagecode2-country/regioncode2 ». « languagecode2 » est un code à deux lettres minuscules dérivé de la norme ISO 639-1, tandis que « country/regioncode2 » est dérivé de la norme ISO 3166 et se compose généralement de deux lettres majuscules ou d’une balise de langue BCP-47. Par exemple, l’anglais américain est en-US.
data
Binaire
Données qui représentent les conditions d’utilisation du document PDF.
Réponse
Si elle réussit, cette méthode renvoie un 201, Created code de réponse et un objet de contrat dans le corps de la réponse.
Exemple
Demande
Dans le corps de la demande, fournissez une représentation JSON de l’objet contrat .
POST https://graph.microsoft.com/v1.0/identityGovernance/termsOfUse/agreements
Content-type: application/json
{
"displayName": "Contoso ToU for guest users",
"isViewingBeforeAcceptanceRequired": true,
"files": [
{
"fileName": "TOU.pdf",
"language": "en",
"isDefault": true,
"fileData": {
"data": "SGVsbG8gd29ybGQ=//truncated-binary"
}
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new Agreement
{
DisplayName = "Contoso ToU for guest users",
IsViewingBeforeAcceptanceRequired = true,
Files = new List<AgreementFileLocalization>
{
new AgreementFileLocalization
{
FileName = "TOU.pdf",
Language = "en",
IsDefault = true,
FileData = new AgreementFileData
{
Data = Convert.FromBase64String("SGVsbG8gd29ybGQ=//truncated-binary"),
},
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.IdentityGovernance.TermsOfUse.Agreements.PostAsync(requestBody);
// 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.NewAgreement()
displayName := "Contoso ToU for guest users"
requestBody.SetDisplayName(&displayName)
isViewingBeforeAcceptanceRequired := true
requestBody.SetIsViewingBeforeAcceptanceRequired(&isViewingBeforeAcceptanceRequired)
agreementFileLocalization := graphmodels.NewAgreementFileLocalization()
fileName := "TOU.pdf"
agreementFileLocalization.SetFileName(&fileName)
language := "en"
agreementFileLocalization.SetLanguage(&language)
isDefault := true
agreementFileLocalization.SetIsDefault(&isDefault)
fileData := graphmodels.NewAgreementFileData()
data := []byte("sGVsbG8gd29ybGQ=//truncated-binary")
fileData.SetData(&data)
agreementFileLocalization.SetFileData(fileData)
files := []graphmodels.AgreementFileLocalizationable {
agreementFileLocalization,
}
requestBody.SetFiles(files)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
agreements, err := graphClient.IdentityGovernance().TermsOfUse().Agreements().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Agreement agreement = new Agreement();
agreement.setDisplayName("Contoso ToU for guest users");
agreement.setIsViewingBeforeAcceptanceRequired(true);
LinkedList<AgreementFileLocalization> files = new LinkedList<AgreementFileLocalization>();
AgreementFileLocalization agreementFileLocalization = new AgreementFileLocalization();
agreementFileLocalization.setFileName("TOU.pdf");
agreementFileLocalization.setLanguage("en");
agreementFileLocalization.setIsDefault(true);
AgreementFileData fileData = new AgreementFileData();
byte[] data = Base64.getDecoder().decode("SGVsbG8gd29ybGQ=//truncated-binary");
fileData.setData(data);
agreementFileLocalization.setFileData(fileData);
files.add(agreementFileLocalization);
agreement.setFiles(files);
Agreement result = graphClient.identityGovernance().termsOfUse().agreements().post(agreement);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\Agreement;
use Microsoft\Graph\Generated\Models\AgreementFileLocalization;
use Microsoft\Graph\Generated\Models\AgreementFileData;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Agreement();
$requestBody->setDisplayName('Contoso ToU for guest users');
$requestBody->setIsViewingBeforeAcceptanceRequired(true);
$filesAgreementFileLocalization1 = new AgreementFileLocalization();
$filesAgreementFileLocalization1->setFileName('TOU.pdf');
$filesAgreementFileLocalization1->setLanguage('en');
$filesAgreementFileLocalization1->setIsDefault(true);
$filesAgreementFileLocalization1FileData = new AgreementFileData();
$filesAgreementFileLocalization1FileData->setData(\GuzzleHttp\Psr7\Utils::streamFor(base64_decode('SGVsbG8gd29ybGQ=//truncated-binary')));
$filesAgreementFileLocalization1->setFileData($filesAgreementFileLocalization1FileData);
$filesArray []= $filesAgreementFileLocalization1;
$requestBody->setFiles($filesArray);
$result = $graphServiceClient->identityGovernance()->termsOfUse()->agreements()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.agreement import Agreement
from msgraph.generated.models.agreement_file_localization import AgreementFileLocalization
from msgraph.generated.models.agreement_file_data import AgreementFileData
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Agreement(
display_name = "Contoso ToU for guest users",
is_viewing_before_acceptance_required = True,
files = [
AgreementFileLocalization(
file_name = "TOU.pdf",
language = "en",
is_default = True,
file_data = AgreementFileData(
data = base64.urlsafe_b64decode("SGVsbG8gd29ybGQ=//truncated-binary"),
),
),
],
)
result = await graph_client.identity_governance.terms_of_use.agreements.post(request_body)