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 .
Attention
Les applications existantes qui utilisent cette fonctionnalité avec baseTask ou baseTaskList doivent être mises à jour, car l’ensemble d’API de tâches basé sur ces ressources est déconseillé à compter du 31 mai 2022. Cet ensemble d'API cessera de renvoyer des données le 31 août 2022. Utilisez l’ensemble d’API basé sur todoTask.
Créez une extension d’ouverture (objet openTypeExtension) et ajoutez des propriétés personnalisées dans une instance nouvelle ou existante d’une ressource. Vous pouvez créer une extension ouverteouverte dans une instance de ressource et y stocker des données personnalisées dans la même opération, à l’exception de ressources spécifiques.
Le tableau de la section Autorisations répertorie les ressources qui prennent en charge les extensions ouvertes.
Remarque : si vous créez des extensions ouvertes sur ressources Outlook, voirconsidérations relatives à Outlook spécifiques dans type de ressource openTypeExtension.
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
En fonction de la ressource que vous créez l’extension dans et l’autorisation de type (délégué ou application) demandé, l’autorisation spécifiée dans le tableau suivant est moins requise privilégiée pour appeler cette API. Pour en savoir plus, notamment sur les Mesures de prudence avant de choisir des autorisations plus privilégiées, recherchez ces autorisations dans Autorisations.
| Ressource prise en charge |
Déléguée (compte professionnel ou scolaire) |
Déléguée (compte Microsoft personnel) |
Application |
|
appareil |
Directory.AccessAsUser.All |
Non prise en charge. |
Device.ReadWrite.All |
|
driveItem |
Files.ReadWrite |
Files.ReadWrite |
Non prise en charge. |
|
event |
Calendars.ReadWrite |
Calendars.ReadWrite |
Calendars.ReadWrite |
|
group |
Group.ReadWrite.All |
Non prise en charge. |
Group.ReadWrite.All |
|
group event |
Group.ReadWrite.All |
Non prise en charge. |
Non prise en charge. |
|
group post |
Group.ReadWrite.All |
Non prise en charge. |
Group.ReadWrite.All |
|
message |
Mail.ReadWrite |
Mail.ReadWrite |
Mail.ReadWrite |
|
organization |
Organization.ReadWrite.All |
Non prise en charge. |
Organization.ReadWrite.All |
|
personal contact |
Contacts.ReadWrite |
Contacts.ReadWrite |
Contacts.ReadWrite |
|
site |
Sites.ReadWrite.All |
Non prise en charge. |
Non prise en charge. |
|
todoTask |
Tasks.ReadWrite |
Tasks.ReadWrite |
Non prise en charge. |
|
todoTaskList |
Tasks.ReadWrite |
Tasks.ReadWrite |
Non prise en charge. |
|
user |
User.ReadWrite |
Non prise en charge. |
User.ReadWrite.All |
|
baseTask (déconseillé) |
Tasks.ReadWrite |
Tasks.ReadWrite |
Non prise en charge. |
|
baseTaskList (déconseillé) |
Tasks.ReadWrite |
Tasks.ReadWrite |
Non prise en charge. |
Requête HTTP
Créer une extension dans une nouvelle instance de la ressource
Utilisez la même requête REST qui vous permet de créer l’instance.
POST /users/{userId|userPrincipalName}/events
POST /users/{userId|userPrincipalName}/messages
POST /groups/{userId}/events
POST /groups/{userId}/threads/{threadId}/posts/{postId}/reply
POST /users/{userId|userPrincipalName}/contacts
POST /users/{userId|userPrincipalName}/todo/lists/{listId}/tasks
POST /users/{userId|userPrincipalName}/todo/lists
POST /users/{userId|userPrincipalName}/tasks/lists/{listId}/tasks
POST /users/{userId|userPrincipalName}/tasks/lists
POST /drive/items/{itemId}/children
Remarque: La syntaxe ci-dessus présente quelques techniques courantes pour créer les instances de ressource prises en charge. Toutes les autres syntaxes POST qui vous permettent de créer ces instances de ressource prennent en charge la création des extensions d’ouverture dans celles-ci de façon similaire.
Reportez-vous à la section Corps de la demande concernant l’inclusion des propriétés de la nouvelle instance de la ressource et de l’extension dans le corps de la demande.
Créer une extension dans une instance de la ressource existants
Identifiez l’instance de la ressource dans la demande et effectuez unePOST sur la propriété de navigation extensions.
POST /administrativeunits/{administrativeUnitId}/extensions
POST /devices/{deviceId}/extensions
POST /users/{userId|userPrincipalName}/events/{eventId}/extensions
POST /groups/{groupId}/extensions
POST /groups/{groupId}/events/{eventId}/extensions
POST /groups/{groupId}/threads/{threadId}/posts/{postId}/extensions
POST /users/{userId|userPrincipalName}/messages/{messageId}/extensions
POST /organization/{organizationId}/extensions
POST /users/{userId|userPrincipalName}/contacts/{contactId}/extensions
POST /users/{userId|userPrincipalName}/extensions
POST /users/{userId|userPrincipalName}/todo/lists/{listId}/tasks/{taskId}/extensions
POST /users/{userId|userPrincipalName}/todo/lists/{listId}/extensions
POST /users/{userId|userPrincipalName}/tasks/lists/{listId}/tasks/{taskId}/extensions
POST /users/{userId|userPrincipalName}/tasks/lists/{listId}/extensions
POST /drive/items/{itemId}/extensions
POST /sites/{siteId}/extensions
Remarque: La syntaxe ci-dessus présente quelques techniques courantes d’identification d’une instance de ressource, afin de créer une extension dans celle-ci. Toutes les autres syntaxes qui vous permettent d’identifier ces instances de ressource prennent en charge la création des extensions d’ouverture dans celles-ci de façon similaire.
Reportez-vous à la section Corps de la demande concernant l’inclusion de l’extension dans le corps de la demande.
Corps de la demande
Fournissez un corps JSON d’un openTypeExtension, avec les paires nom-valeur requises suivantes et toutes les données personnalisées supplémentaires. Les données de la charge utile JSON peuvent être des types primitifs ou des tableaux de types primitifs.
| Nom |
Valeur |
| @odata.type |
microsoft.graph.openTypeExtension |
| extensionName |
Chaîne unique |
Lorsque vous créez une extension dans une nouvelle instance de la ressource, outre le nouvel objet openTypeExtension, fournissez une représentation JSON des propriétés applicables pour créer cette instance de la ressource.
Réponse
Code de réponse
En fonction de l’opération, le code de réponse peut être 201 Created ou 202 Accepted.
Lorsque vous créez une extension à l’aide de la même opération qui vous permet de créer une instance de la ressource, l’opération renvoie le même code réponse qu’elle renvoie lorsque vous utilisez l’opération pour créer l’instance de la ressource sans l’extension.
Consultez les rubriques relatives à la création de l’instance, comme indiqué ci-dessus.
Corps de la réponse
| Scénario |
Ressource |
Corps de la réponse |
| Création d’une extension lors de la création explicite d’une nouvelle instance de la ressource |
contact, event, message |
Inclut la nouvelle instance développée avec l’objet openTypeExtension. |
| Création d’une extension lors de la création implicite d’une instance de la ressource |
post |
La réponse inclut uniquement un code de réponse, et n’a pas de corps. |
| Création d’une extension dans une instance de la ressource existante |
Toutes les ressources prises en charge |
Inclut l’objet openTypeExtension. |
Exemple
Demande 1
Le premier exemple crée un message et une extension dans le même appel. Le corps de la demande inclut les éléments suivants :
POST https://graph.microsoft.com/beta/me/messages
Content-Type: application/json
{
"subject": "Annual review",
"body": {
"contentType": "HTML",
"content": "You should be proud!"
},
"toRecipients": [
{
"emailAddress": {
"address": "rufus@contoso.com"
}
}
],
"extensions": [
{
"@odata.type": "microsoft.graph.openTypeExtension",
"extensionName": "Com.Contoso.Referral",
"companyName": "Wingtip Toys",
"expirationDate": "2015-12-30T11:00:00.000Z",
"dealValue": 10000
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new Message
{
Subject = "Annual review",
Body = new ItemBody
{
ContentType = BodyType.Html,
Content = "You should be proud!",
},
ToRecipients = new List<Recipient>
{
new Recipient
{
EmailAddress = new EmailAddress
{
Address = "rufus@contoso.com",
},
},
},
Extensions = new List<Extension>
{
new OpenTypeExtension
{
OdataType = "microsoft.graph.openTypeExtension",
ExtensionName = "Com.Contoso.Referral",
AdditionalData = new Dictionary<string, object>
{
{
"companyName" , "Wingtip Toys"
},
{
"expirationDate" , "2015-12-30T11:00:00.000Z"
},
{
"dealValue" , 10000
},
},
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.Messages.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"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewMessage()
subject := "Annual review"
requestBody.SetSubject(&subject)
body := graphmodels.NewItemBody()
contentType := graphmodels.HTML_BODYTYPE
body.SetContentType(&contentType)
content := "You should be proud!"
body.SetContent(&content)
requestBody.SetBody(body)
recipient := graphmodels.NewRecipient()
emailAddress := graphmodels.NewEmailAddress()
address := "rufus@contoso.com"
emailAddress.SetAddress(&address)
recipient.SetEmailAddress(emailAddress)
toRecipients := []graphmodels.Recipientable {
recipient,
}
requestBody.SetToRecipients(toRecipients)
extension := graphmodels.NewOpenTypeExtension()
extensionName := "Com.Contoso.Referral"
extension.SetExtensionName(&extensionName)
additionalData := map[string]interface{}{
"companyName" : "Wingtip Toys",
"expirationDate" : "2015-12-30T11:00:00.000Z",
"dealValue" : int32(10000) ,
}
extension.SetAdditionalData(additionalData)
extensions := []graphmodels.Extensionable {
extension,
}
requestBody.SetExtensions(extensions)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
messages, err := graphClient.Me().Messages().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Message message = new Message();
message.setSubject("Annual review");
ItemBody body = new ItemBody();
body.setContentType(BodyType.Html);
body.setContent("You should be proud!");
message.setBody(body);
LinkedList<Recipient> toRecipients = new LinkedList<Recipient>();
Recipient recipient = new Recipient();
EmailAddress emailAddress = new EmailAddress();
emailAddress.setAddress("rufus@contoso.com");
recipient.setEmailAddress(emailAddress);
toRecipients.add(recipient);
message.setToRecipients(toRecipients);
LinkedList<Extension> extensions = new LinkedList<Extension>();
OpenTypeExtension extension = new OpenTypeExtension();
extension.setOdataType("microsoft.graph.openTypeExtension");
extension.setExtensionName("Com.Contoso.Referral");
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("companyName", "Wingtip Toys");
additionalData.put("expirationDate", "2015-12-30T11:00:00.000Z");
additionalData.put("dealValue", 10000);
extension.setAdditionalData(additionalData);
extensions.add(extension);
message.setExtensions(extensions);
Message result = graphClient.me().messages().post(message);
const options = {
authProvider,
};
const client = Client.init(options);
const message = {
subject: 'Annual review',
body: {
contentType: 'HTML',
content: 'You should be proud!'
},
toRecipients: [
{
emailAddress: {
address: 'rufus@contoso.com'
}
}
],
extensions: [
{
'@odata.type': 'microsoft.graph.openTypeExtension',
extensionName: 'Com.Contoso.Referral',
companyName: 'Wingtip Toys',
expirationDate: '2015-12-30T11:00:00.000Z',
dealValue: 10000
}
]
};
await client.api('/me/messages')
.version('beta')
.post(message);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\Message;
use Microsoft\Graph\Beta\Generated\Models\ItemBody;
use Microsoft\Graph\Beta\Generated\Models\BodyType;
use Microsoft\Graph\Beta\Generated\Models\Recipient;
use Microsoft\Graph\Beta\Generated\Models\EmailAddress;
use Microsoft\Graph\Beta\Generated\Models\Extension;
use Microsoft\Graph\Beta\Generated\Models\OpenTypeExtension;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Message();
$requestBody->setSubject('Annual review');
$body = new ItemBody();
$body->setContentType(new BodyType('hTML'));
$body->setContent('You should be proud!');
$requestBody->setBody($body);
$toRecipientsRecipient1 = new Recipient();
$toRecipientsRecipient1EmailAddress = new EmailAddress();
$toRecipientsRecipient1EmailAddress->setAddress('rufus@contoso.com');
$toRecipientsRecipient1->setEmailAddress($toRecipientsRecipient1EmailAddress);
$toRecipientsArray []= $toRecipientsRecipient1;
$requestBody->setToRecipients($toRecipientsArray);
$extensionsExtension1 = new OpenTypeExtension();
$extensionsExtension1->setOdataType('microsoft.graph.openTypeExtension');
$extensionsExtension1->setExtensionName('Com.Contoso.Referral');
$additionalData = [
'companyName' => 'Wingtip Toys',
'expirationDate' => '2015-12-30T11:00:00.000Z',
'dealValue' => 10000,
];
$extensionsExtension1->setAdditionalData($additionalData);
$extensionsArray []= $extensionsExtension1;
$requestBody->setExtensions($extensionsArray);
$result = $graphServiceClient->me()->messages()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Mail
$params = @{
subject = "Annual review"
body = @{
contentType = "HTML"
content = "You should be proud!"
}
toRecipients = @(
@{
emailAddress = @{
address = "rufus@contoso.com"
}
}
)
extensions = @(
@{
"@odata.type" = "microsoft.graph.openTypeExtension"
extensionName = "Com.Contoso.Referral"
companyName = "Wingtip Toys"
expirationDate = "2015-12-30T11:00:00.000Z"
dealValue =
}
)
}
# A UPN can also be used as -UserId.
New-MgBetaUserMessage -UserId $userId -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.message import Message
from msgraph_beta.generated.models.item_body import ItemBody
from msgraph_beta.generated.models.body_type import BodyType
from msgraph_beta.generated.models.recipient import Recipient
from msgraph_beta.generated.models.email_address import EmailAddress
from msgraph_beta.generated.models.extension import Extension
from msgraph_beta.generated.models.open_type_extension import OpenTypeExtension
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Message(
subject = "Annual review",
body = ItemBody(
content_type = BodyType.Html,
content = "You should be proud!",
),
to_recipients = [
Recipient(
email_address = EmailAddress(
address = "rufus@contoso.com",
),
),
],
extensions = [
OpenTypeExtension(
odata_type = "microsoft.graph.openTypeExtension",
extension_name = "Com.Contoso.Referral",
additional_data = {
"company_name" : "Wingtip Toys",
"expiration_date" : "2015-12-30T11:00:00.000Z",
"deal_value" : 10000,
}
),
],
)
result = await graph_client.me.messages.post(request_body)
Réponse 1
Voici la réponse pour le premier exemple. Le corps de la réponse inclut les propriétés du nouveau message et les informations suivantes sur la nouvelle extension :
- La propriété id avec le nom complet de
microsoft.graph.openTypeExtension.Com.Contoso.Referral.
- La propriété par défaut extensionName spécifiée dans la demande.
- Les données personnalisées spécifiées dans la demande stockée sous la forme de 3 propriétés personnalisées.
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
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#Me/messages/$entity",
"@odata.id": "https://graph.microsoft.com/beta/users('ddfc984d-b826-40d7-b48b-57002df800e5@1717f226-49d1-4d0c-9d74-709fad664b77')/messages
('AAMkAGEbs88AAB84uLuAAA=')",
"@odata.etag": "W/\"CQAAABYAAACY4MQpaFz9SbqUDe4+bs88AAB88LOj\"",
"id": "AAMkAGEbs88AAB84uLuAAA=",
"createdDateTime": "2015-10-30T03:03:43Z",
"lastModifiedDateTime": "2015-10-30T03:03:43Z",
"changeKey": "CQAAABYAAACY4MQpaFz9SbqUDe4+bs88AAB88LOj",
"categories": [ ],
"receivedDateTime": "2015-10-30T03:03:43Z",
"sentDateTime": "2015-10-30T03:03:43Z",
"hasAttachments": false,
"subject": "Annual review",
"body": {
"contentType": "HTML",
"content": "<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r
\n<meta content=\"text/html; charset=us-ascii\">\r\n</head>\r\n<body>\r\nYou should be proud!\r\n</body>\r
\n</html>\r\n"
},
"bodyPreview": "You should be proud!",
"importance": "Normal",
"parentFolderId": "AQMkAGEwAAAIBDwAAAA==",
"sender": null,
"from": null,
"toRecipients": [
{
"emailAddress": {
"address": "rufus@contoso.com",
"name": "John Doe"
}
}
],
"ccRecipients": [ ],
"bccRecipients": [ ],
"replyTo": [ ],
"conversationId": "AAQkAGEFGugh3SVdMzzc=",
"isDeliveryReceiptRequested": false,
"isReadReceiptRequested": false,
"isRead": true,
"isDraft": true,
"webLink": "https://outlook.office.com/owa/?
ItemID=AAMkAGEbs88AAB84uLuAAA%3D&exvsurl=1&viewmodel=ReadMessageItem",
"inferenceClassification": "Focused",
"extensions": [
{
"@odata.type": "#microsoft.graph.openTypeExtension",
"@odata.id": "https://graph.microsoft.com/beta/users('ddfc984d-b826-40d7-b48b-57002df800e5@1717f226-49d1-4d0c-9d74-709fad664b77')/messages
('AAMkAGEbs88AAB84uLuAAA=')/extensions('microsoft.graph.openTypeExtension.Com.Contoso.Referral')",
"id": "microsoft.graph.openTypeExtension.Com.Contoso.Referral",
"extensionName": "Com.Contoso.Referral",
"companyName": "Wingtip Toys",
"expirationDate": "2015-12-30T11:00:00.000Z",
"dealValue": 10000
}
]
}
Demande 2
Le deuxième exemple crée une extension dans le message spécifié. Le corps de la demande inclut les informations suivantes sur l’extension :
- Le type
microsoft.graph.openTypeExtension.
- Le nom de l’extension « Com.Contoso.Referral ».
- Les données supplémentaires à stocker sous la forme de 3 propriétés personnalisées dans la charge utile JSON :
companyName, dealValue et expirationDate.
POST https://graph.microsoft.com/beta/me/messages/AAMkAGE1M2IyNGNmLTI5MTktNDUyZi1iOTVl===/extensions
Content-Type: application/json
{
"@odata.type" : "microsoft.graph.openTypeExtension",
"extensionName" : "Com.Contoso.Referral",
"companyName" : "Wingtip Toys",
"dealValue" : 500050,
"expirationDate" : "2015-12-03T10:00:00.000Z"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new OpenTypeExtension
{
OdataType = "microsoft.graph.openTypeExtension",
ExtensionName = "Com.Contoso.Referral",
AdditionalData = new Dictionary<string, object>
{
{
"companyName" , "Wingtip Toys"
},
{
"dealValue" , 500050
},
{
"expirationDate" , "2015-12-03T10:00:00.000Z"
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.Messages["{message-id}"].Extensions.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"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewExtension()
extensionName := "Com.Contoso.Referral"
requestBody.SetExtensionName(&extensionName)
additionalData := map[string]interface{}{
"companyName" : "Wingtip Toys",
"dealValue" : int32(500050) ,
"expirationDate" : "2015-12-03T10:00:00.000Z",
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
extensions, err := graphClient.Me().Messages().ByMessageId("message-id").Extensions().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
OpenTypeExtension extension = new OpenTypeExtension();
extension.setOdataType("microsoft.graph.openTypeExtension");
extension.setExtensionName("Com.Contoso.Referral");
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("companyName", "Wingtip Toys");
additionalData.put("dealValue", 500050);
additionalData.put("expirationDate", "2015-12-03T10:00:00.000Z");
extension.setAdditionalData(additionalData);
Extension result = graphClient.me().messages().byMessageId("{message-id}").extensions().post(extension);
const options = {
authProvider,
};
const client = Client.init(options);
const extension = {
'@odata.type': 'microsoft.graph.openTypeExtension',
extensionName: 'Com.Contoso.Referral',
companyName: 'Wingtip Toys',
dealValue: 500050,
expirationDate: '2015-12-03T10:00:00.000Z'
};
await client.api('/me/messages/AAMkAGE1M2IyNGNmLTI5MTktNDUyZi1iOTVl===/extensions')
.version('beta')
.post(extension);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\OpenTypeExtension;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new OpenTypeExtension();
$requestBody->setOdataType('microsoft.graph.openTypeExtension');
$requestBody->setExtensionName('Com.Contoso.Referral');
$additionalData = [
'companyName' => 'Wingtip Toys',
'dealValue' => 500050,
'expirationDate' => '2015-12-03T10:00:00.000Z',
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->me()->messages()->byMessageId('message-id')->extensions()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Mail
$params = @{
"@odata.type" = "microsoft.graph.openTypeExtension"
extensionName = "Com.Contoso.Referral"
companyName = "Wingtip Toys"
dealValue =
expirationDate = "2015-12-03T10:00:00.000Z"
}
# A UPN can also be used as -UserId.
New-MgBetaUserMessageExtension -UserId $userId -MessageId $messageId -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.open_type_extension import OpenTypeExtension
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = OpenTypeExtension(
odata_type = "microsoft.graph.openTypeExtension",
extension_name = "Com.Contoso.Referral",
additional_data = {
"company_name" : "Wingtip Toys",
"deal_value" : 500050,
"expiration_date" : "2015-12-03T10:00:00.000Z",
}
)
result = await graph_client.me.messages.by_message_id('message-id').extensions.post(request_body)
Réponse 2
Voici la réponse pour le deuxième exemple. Le corps de la réponse inclut les informations suivantes sur la nouvelle extension :
- La propriété par défaut extensionName.
- La propriété id avec le nom complet de
microsoft.graph.openTypeExtension.Com.Contoso.Referral.
- Les données personnalisées à stocker.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#Me/messages('AAMkAGE1M2IyNGNmLTI5MTktNDUyZi1iOTVl===')/extensions/$entity",
"@odata.type": "#microsoft.graph.openTypeExtension",
"@odata.id": "https://graph.microsoft.com/beta/users('ddfc984d-b826-40d7-b48b-57002df85e00@1717f226-49d1-4d0c-9d74-709fad6677b4')/messages('AAMkAGE1M2IyNGNmLTI5MTktNDUyZi1iOTVl===')/extensions
('microsoft.graph.openTypeExtension.Com.Contoso.Referral')",
"extensionName": "Com.Contoso.Referral",
"id": "microsoft.graph.openTypeExtension.Com.Contoso.Referral",
"companyName": "Wingtip Toys",
"dealValue": 500050,
"expirationDate": "2015-12-03T10:00:00.000Z"
}
Demande 3
Le troisième exemple crée une extension dans l’événement de groupe spécifié. Le corps de la demande inclut les informations suivantes sur l’extension :
- Le type
microsoft.graph.openTypeExtension.
- Le nom de l’extension « Com.Contoso.Deal ».
- Les données supplémentaires à stocker sous la forme de 3 propriétés personnalisées dans la charge utile JSON :
companyName, dealValue et expirationDate.
POST https://graph.microsoft.com/beta/groups/f5480dfd-7d77-4d0b-ba2e-3391953cc74a/events/AAMkADVl17IsAAA=/extensions
Content-type: application/json
{
"@odata.type" : "microsoft.graph.openTypeExtension",
"extensionName" : "Com.Contoso.Deal",
"companyName" : "Alpine Skis",
"dealValue" : 1010100,
"expirationDate" : "2015-07-03T13:04:00.000Z"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new OpenTypeExtension
{
OdataType = "microsoft.graph.openTypeExtension",
ExtensionName = "Com.Contoso.Deal",
AdditionalData = new Dictionary<string, object>
{
{
"companyName" , "Alpine Skis"
},
{
"dealValue" , 1010100
},
{
"expirationDate" , "2015-07-03T13:04:00.000Z"
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Groups["{group-id}"].Events["{event-id}"].Extensions.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"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewExtension()
extensionName := "Com.Contoso.Deal"
requestBody.SetExtensionName(&extensionName)
additionalData := map[string]interface{}{
"companyName" : "Alpine Skis",
"dealValue" : int32(1010100) ,
"expirationDate" : "2015-07-03T13:04:00.000Z",
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
extensions, err := graphClient.Groups().ByGroupId("group-id").Events().ByEventId("event-id").Extensions().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
OpenTypeExtension extension = new OpenTypeExtension();
extension.setOdataType("microsoft.graph.openTypeExtension");
extension.setExtensionName("Com.Contoso.Deal");
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("companyName", "Alpine Skis");
additionalData.put("dealValue", 1010100);
additionalData.put("expirationDate", "2015-07-03T13:04:00.000Z");
extension.setAdditionalData(additionalData);
Extension result = graphClient.groups().byGroupId("{group-id}").events().byEventId("{event-id}").extensions().post(extension);
const options = {
authProvider,
};
const client = Client.init(options);
const extension = {
'@odata.type': 'microsoft.graph.openTypeExtension',
extensionName: 'Com.Contoso.Deal',
companyName: 'Alpine Skis',
dealValue: 1010100,
expirationDate: '2015-07-03T13:04:00.000Z'
};
await client.api('/groups/f5480dfd-7d77-4d0b-ba2e-3391953cc74a/events/AAMkADVl17IsAAA=/extensions')
.version('beta')
.post(extension);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\OpenTypeExtension;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new OpenTypeExtension();
$requestBody->setOdataType('microsoft.graph.openTypeExtension');
$requestBody->setExtensionName('Com.Contoso.Deal');
$additionalData = [
'companyName' => 'Alpine Skis',
'dealValue' => 1010100,
'expirationDate' => '2015-07-03T13:04:00.000Z',
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->groups()->byGroupId('group-id')->events()->byEventId('event-id')->extensions()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Calendar
$params = @{
"@odata.type" = "microsoft.graph.openTypeExtension"
extensionName = "Com.Contoso.Deal"
companyName = "Alpine Skis"
dealValue =
expirationDate = "2015-07-03T13:04:00.000Z"
}
New-MgBetaGroupEventExtension -GroupId $groupId -EventId $eventId -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.open_type_extension import OpenTypeExtension
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = OpenTypeExtension(
odata_type = "microsoft.graph.openTypeExtension",
extension_name = "Com.Contoso.Deal",
additional_data = {
"company_name" : "Alpine Skis",
"deal_value" : 1010100,
"expiration_date" : "2015-07-03T13:04:00.000Z",
}
)
result = await graph_client.groups.by_group_id('group-id').events.by_event_id('event-id').extensions.post(request_body)
Réponse 3
Voici la réponse pour la troisième demande.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#groups('f5480dfd-7d77-4d0b-ba2e-3391953cc74a')/events('AAMkADVl7IsAAA%3D')/extensions/$entity",
"@odata.type": "#microsoft.graph.openTypeExtension",
"id": "microsoft.graph.openTypeExtension.Com.Contoso.Deal",
"extensionName": "Com.Contoso.Deal",
"companyName": "Alpine Skis",
"dealValue": 1010100,
"expirationDate": "2015-07-03T13:04:00Z"
}
Demande 4
Le quatrième exemple crée une extension dans un nouveau billet de groupe, à l’aide de la même action reply d’un billet de groupe existant. L’action reply crée un nouveau billet, et une nouvelle extension incorporée dans le billet. Le corps de la demande inclut la propriété post, qui à son tour contient le corps du nouveau billet, ainsi que les informations suivantes sur la nouvelle extension :
- Le type
microsoft.graph.openTypeExtension.
- Le nom de l’extension « Com.Contoso.HR ».
- Les données supplémentaires à stocker sous la forme de 3 propriétés personnalisées dans la charge utile JSON :
companyName, expirationDate et le tableau de chaînes topPicks.
POST https://graph.microsoft.com/beta/groups/37df2ff0-0de0-4c33-8aee-75289364aef6/threads/AAQkADJizZJpEWwqDHsEpV_KA==/posts/AAMkADJiUg96QZUkA-ICwMubAAC1heiSAAA=/reply
Content-type: application/json
{
"post": {
"body": {
"contentType": "html",
"content": "<html><body><div><div><div><div>When and where? </div></div></div></div></body></html>"
},
"extensions": [
{
"@odata.type": "microsoft.graph.openTypeExtension",
"extensionName": "Com.Contoso.HR",
"companyName": "Contoso",
"expirationDate": "2015-07-03T13:04:00.000Z",
"topPicks": [
"Employees only",
"Add spouse or guest",
"Add family"
]
}
]
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Groups.Item.Threads.Item.Posts.Item.Reply;
using Microsoft.Graph.Beta.Models;
var requestBody = new ReplyPostRequestBody
{
Post = new Post
{
Body = new ItemBody
{
ContentType = BodyType.Html,
Content = "<html><body><div><div><div><div>When and where? </div></div></div></div></body></html>",
},
Extensions = new List<Extension>
{
new OpenTypeExtension
{
OdataType = "microsoft.graph.openTypeExtension",
ExtensionName = "Com.Contoso.HR",
AdditionalData = new Dictionary<string, object>
{
{
"companyName" , "Contoso"
},
{
"expirationDate" , "2015-07-03T13:04:00.000Z"
},
{
"topPicks" , new List<string>
{
"Employees only",
"Add spouse or guest",
"Add family",
}
},
},
},
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Groups["{group-id}"].Threads["{conversationThread-id}"].Posts["{post-id}"].Reply.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"
graphgroups "github.com/microsoftgraph/msgraph-beta-sdk-go/groups"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphgroups.NewReplyPostRequestBody()
post := graphmodels.NewPost()
body := graphmodels.NewItemBody()
contentType := graphmodels.HTML_BODYTYPE
body.SetContentType(&contentType)
content := "<html><body><div><div><div><div>When and where? </div></div></div></div></body></html>"
body.SetContent(&content)
post.SetBody(body)
extension := graphmodels.NewOpenTypeExtension()
extensionName := "Com.Contoso.HR"
extension.SetExtensionName(&extensionName)
additionalData := map[string]interface{}{
"companyName" : "Contoso",
"expirationDate" : "2015-07-03T13:04:00.000Z",
topPicks := []string {
"Employees only",
"Add spouse or guest",
"Add family",
}
}
extension.SetAdditionalData(additionalData)
extensions := []graphmodels.Extensionable {
extension,
}
post.SetExtensions(extensions)
requestBody.SetPost(post)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Groups().ByGroupId("group-id").Threads().ByConversationThreadId("conversationThread-id").Posts().ByPostId("post-id").Reply().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.groups.item.threads.item.posts.item.reply.ReplyPostRequestBody replyPostRequestBody = new com.microsoft.graph.beta.groups.item.threads.item.posts.item.reply.ReplyPostRequestBody();
Post post = new Post();
ItemBody body = new ItemBody();
body.setContentType(BodyType.Html);
body.setContent("<html><body><div><div><div><div>When and where? </div></div></div></div></body></html>");
post.setBody(body);
LinkedList<Extension> extensions = new LinkedList<Extension>();
OpenTypeExtension extension = new OpenTypeExtension();
extension.setOdataType("microsoft.graph.openTypeExtension");
extension.setExtensionName("Com.Contoso.HR");
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("companyName", "Contoso");
additionalData.put("expirationDate", "2015-07-03T13:04:00.000Z");
LinkedList<String> topPicks = new LinkedList<String>();
topPicks.add("Employees only");
topPicks.add("Add spouse or guest");
topPicks.add("Add family");
additionalData.put("topPicks", topPicks);
extension.setAdditionalData(additionalData);
extensions.add(extension);
post.setExtensions(extensions);
replyPostRequestBody.setPost(post);
graphClient.groups().byGroupId("{group-id}").threads().byConversationThreadId("{conversationThread-id}").posts().byPostId("{post-id}").reply().post(replyPostRequestBody);
const options = {
authProvider,
};
const client = Client.init(options);
const reply = {
post: {
body: {
contentType: 'html',
content: '<html><body><div><div><div><div>When and where? </div></div></div></div></body></html>'
},
extensions: [
{
'@odata.type': 'microsoft.graph.openTypeExtension',
extensionName: 'Com.Contoso.HR',
companyName: 'Contoso',
expirationDate: '2015-07-03T13:04:00.000Z',
topPicks: [
'Employees only',
'Add spouse or guest',
'Add family'
]
}
]
}
};
await client.api('/groups/37df2ff0-0de0-4c33-8aee-75289364aef6/threads/AAQkADJizZJpEWwqDHsEpV_KA==/posts/AAMkADJiUg96QZUkA-ICwMubAAC1heiSAAA=/reply')
.version('beta')
.post(reply);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Groups\Item\Threads\Item\Posts\Item\Reply\ReplyPostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\Post;
use Microsoft\Graph\Beta\Generated\Models\ItemBody;
use Microsoft\Graph\Beta\Generated\Models\BodyType;
use Microsoft\Graph\Beta\Generated\Models\Extension;
use Microsoft\Graph\Beta\Generated\Models\OpenTypeExtension;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new ReplyPostRequestBody();
$post = new Post();
$postBody = new ItemBody();
$postBody->setContentType(new BodyType('html'));
$postBody->setContent('<html><body><div><div><div><div>When and where? </div></div></div></div></body></html>');
$post->setBody($postBody);
$extensionsExtension1 = new OpenTypeExtension();
$extensionsExtension1->setOdataType('microsoft.graph.openTypeExtension');
$extensionsExtension1->setExtensionName('Com.Contoso.HR');
$additionalData = [
'companyName' => 'Contoso',
'expirationDate' => '2015-07-03T13:04:00.000Z',
'topPicks' => [
'Employees only', 'Add spouse or guest', 'Add family', ],
];
$extensionsExtension1->setAdditionalData($additionalData);
$extensionsArray []= $extensionsExtension1;
$post->setExtensions($extensionsArray);
$requestBody->setPost($post);
$graphServiceClient->groups()->byGroupId('group-id')->threads()->byConversationThreadId('conversationThread-id')->posts()->byPostId('post-id')->reply()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Groups
$params = @{
post = @{
body = @{
contentType = "html"
content = "<html><body><div><div><div><div>When and where? </div></div></div></div></body></html>"
}
extensions = @(
@{
"@odata.type" = "microsoft.graph.openTypeExtension"
extensionName = "Com.Contoso.HR"
companyName = "Contoso"
expirationDate = "2015-07-03T13:04:00.000Z"
topPicks = @(
"Employees only"
"Add spouse or guest"
"Add family"
)
}
)
}
}
Invoke-MgBetaReplyGroupThreadPost -GroupId $groupId -ConversationThreadId $conversationThreadId -PostId $postId -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.groups.item.threads.item.posts.item.reply.reply_post_request_body import ReplyPostRequestBody
from msgraph_beta.generated.models.post import Post
from msgraph_beta.generated.models.item_body import ItemBody
from msgraph_beta.generated.models.body_type import BodyType
from msgraph_beta.generated.models.extension import Extension
from msgraph_beta.generated.models.open_type_extension import OpenTypeExtension
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = ReplyPostRequestBody(
post = Post(
body = ItemBody(
content_type = BodyType.Html,
content = "<html><body><div><div><div><div>When and where? </div></div></div></div></body></html>",
),
extensions = [
OpenTypeExtension(
odata_type = "microsoft.graph.openTypeExtension",
extension_name = "Com.Contoso.HR",
additional_data = {
"company_name" : "Contoso",
"expiration_date" : "2015-07-03T13:04:00.000Z",
"top_picks" : [
"Employees only",
"Add spouse or guest",
"Add family",
],
}
),
],
),
)
await graph_client.groups.by_group_id('group-id').threads.by_conversation_thread_id('conversationThread-id').posts.by_post_id('post-id').reply.post(request_body)
Réponse 4
Voici la réponse pour le quatrième exemple. La création réussie d’une extension dans un nouveau billet de groupe génère uniquement le code de réponse HTTP 202.
HTTP/1.1 202 Accepted
Content-type: text/plain
Content-Length: 0
Demande 5
Le cinquième exemple crée une extension dans un nouveau billet de groupe à l’aide de la même opération POST pour créer une conversation. L’opération POST crée une nouvelle conversation, un nouveau thread, un nouveau billet, et une nouvelle extension incorporée dans le billet. Le corps de la demande inclut les propriétés Topic et Threads, et un objet enfant post pour la nouvelle conversation. L’objet post contient à son tour le corps du nouveau billet et les informations suivantes sur l’extension :
- Le type
microsoft.graph.openTypeExtension.
- Le nom de l’extension « Com.Contoso.HR ».
- Les données supplémentaires à stocker sous la forme de 3 propriétés personnalisées dans la charge utile JSON :
companyName, expirationDate et le tableau de chaînes topPicks.
POST https://graph.microsoft.com/beta/groups/37df2ff0-0de0-4c33-8aee-75289364aef6/conversations
Content-type: application/json
{
"Topic": "Does anyone have a second?",
"Threads": [
{
"Posts": [
{
"Body": {
"ContentType": "HTML",
"Content": "This is urgent!"
},
"Extensions": [
{
"@odata.type": "microsoft.graph.openTypeExtension",
"extensionName": "Com.Contoso.Benefits",
"companyName": "Contoso",
"expirationDate": "2016-08-03T11:00:00.000Z",
"topPicks": [
"Employees only",
"Add spouse or guest",
"Add family"
]
}
]
}
]
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new Conversation
{
Topic = "Does anyone have a second?",
Threads = new List<ConversationThread>
{
new ConversationThread
{
Posts = new List<Post>
{
new Post
{
Body = new ItemBody
{
ContentType = BodyType.Html,
Content = "This is urgent!",
},
Extensions = new List<Extension>
{
new OpenTypeExtension
{
OdataType = "microsoft.graph.openTypeExtension",
ExtensionName = "Com.Contoso.Benefits",
AdditionalData = new Dictionary<string, object>
{
{
"companyName" , "Contoso"
},
{
"expirationDate" , "2016-08-03T11:00:00.000Z"
},
{
"topPicks" , new List<string>
{
"Employees only",
"Add spouse or guest",
"Add family",
}
},
},
},
},
},
},
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Groups["{group-id}"].Conversations.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"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewConversation()
topic := "Does anyone have a second?"
requestBody.SetTopic(&topic)
conversationThread := graphmodels.NewConversationThread()
post := graphmodels.NewPost()
body := graphmodels.NewItemBody()
contentType := graphmodels.HTML_BODYTYPE
body.SetContentType(&contentType)
content := "This is urgent!"
body.SetContent(&content)
post.SetBody(body)
extension := graphmodels.NewOpenTypeExtension()
extensionName := "Com.Contoso.Benefits"
extension.SetExtensionName(&extensionName)
additionalData := map[string]interface{}{
"companyName" : "Contoso",
"expirationDate" : "2016-08-03T11:00:00.000Z",
topPicks := []string {
"Employees only",
"Add spouse or guest",
"Add family",
}
}
extension.SetAdditionalData(additionalData)
extensions := []graphmodels.Extensionable {
extension,
}
post.SetExtensions(extensions)
posts := []graphmodels.Postable {
post,
}
conversationThread.SetPosts(posts)
threads := []graphmodels.ConversationThreadable {
conversationThread,
}
requestBody.SetThreads(threads)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
conversations, err := graphClient.Groups().ByGroupId("group-id").Conversations().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Conversation conversation = new Conversation();
conversation.setTopic("Does anyone have a second?");
LinkedList<ConversationThread> threads = new LinkedList<ConversationThread>();
ConversationThread conversationThread = new ConversationThread();
LinkedList<Post> posts = new LinkedList<Post>();
Post post = new Post();
ItemBody body = new ItemBody();
body.setContentType(BodyType.Html);
body.setContent("This is urgent!");
post.setBody(body);
LinkedList<Extension> extensions = new LinkedList<Extension>();
OpenTypeExtension extension = new OpenTypeExtension();
extension.setOdataType("microsoft.graph.openTypeExtension");
extension.setExtensionName("Com.Contoso.Benefits");
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("companyName", "Contoso");
additionalData.put("expirationDate", "2016-08-03T11:00:00.000Z");
LinkedList<String> topPicks = new LinkedList<String>();
topPicks.add("Employees only");
topPicks.add("Add spouse or guest");
topPicks.add("Add family");
additionalData.put("topPicks", topPicks);
extension.setAdditionalData(additionalData);
extensions.add(extension);
post.setExtensions(extensions);
posts.add(post);
conversationThread.setPosts(posts);
threads.add(conversationThread);
conversation.setThreads(threads);
Conversation result = graphClient.groups().byGroupId("{group-id}").conversations().post(conversation);
const options = {
authProvider,
};
const client = Client.init(options);
const conversation = {
Topic: 'Does anyone have a second?',
Threads: [
{
Posts: [
{
Body: {
ContentType: 'HTML',
Content: 'This is urgent!'
},
Extensions: [
{
'@odata.type': 'microsoft.graph.openTypeExtension',
extensionName: 'Com.Contoso.Benefits',
companyName: 'Contoso',
expirationDate: '2016-08-03T11:00:00.000Z',
topPicks: [
'Employees only',
'Add spouse or guest',
'Add family'
]
}
]
}
]
}
]
};
await client.api('/groups/37df2ff0-0de0-4c33-8aee-75289364aef6/conversations')
.version('beta')
.post(conversation);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\Conversation;
use Microsoft\Graph\Beta\Generated\Models\ConversationThread;
use Microsoft\Graph\Beta\Generated\Models\Post;
use Microsoft\Graph\Beta\Generated\Models\ItemBody;
use Microsoft\Graph\Beta\Generated\Models\BodyType;
use Microsoft\Graph\Beta\Generated\Models\Extension;
use Microsoft\Graph\Beta\Generated\Models\OpenTypeExtension;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Conversation();
$requestBody->setTopic('Does anyone have a second?');
$threadsConversationThread1 = new ConversationThread();
$postsPost1 = new Post();
$postsPost1Body = new ItemBody();
$postsPost1Body->setContentType(new BodyType('hTML'));
$postsPost1Body->setContent('This is urgent!');
$postsPost1->setBody($postsPost1Body);
$extensionsExtension1 = new OpenTypeExtension();
$extensionsExtension1->setOdataType('microsoft.graph.openTypeExtension');
$extensionsExtension1->setExtensionName('Com.Contoso.Benefits');
$additionalData = [
'companyName' => 'Contoso',
'expirationDate' => '2016-08-03T11:00:00.000Z',
'topPicks' => [
'Employees only', 'Add spouse or guest', 'Add family', ],
];
$extensionsExtension1->setAdditionalData($additionalData);
$extensionsArray []= $extensionsExtension1;
$postsPost1->setExtensions($extensionsArray);
$postsArray []= $postsPost1;
$threadsConversationThread1->setPosts($postsArray);
$threadsArray []= $threadsConversationThread1;
$requestBody->setThreads($threadsArray);
$result = $graphServiceClient->groups()->byGroupId('group-id')->conversations()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Groups
$params = @{
Topic = "Does anyone have a second?"
Threads = @(
@{
Posts = @(
@{
Body = @{
ContentType = "HTML"
Content = "This is urgent!"
}
Extensions = @(
@{
"@odata.type" = "microsoft.graph.openTypeExtension"
extensionName = "Com.Contoso.Benefits"
companyName = "Contoso"
expirationDate = "2016-08-03T11:00:00.000Z"
topPicks = @(
"Employees only"
"Add spouse or guest"
"Add family"
)
}
)
}
)
}
)
}
New-MgBetaGroupConversation -GroupId $groupId -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.conversation import Conversation
from msgraph_beta.generated.models.conversation_thread import ConversationThread
from msgraph_beta.generated.models.post import Post
from msgraph_beta.generated.models.item_body import ItemBody
from msgraph_beta.generated.models.body_type import BodyType
from msgraph_beta.generated.models.extension import Extension
from msgraph_beta.generated.models.open_type_extension import OpenTypeExtension
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Conversation(
topic = "Does anyone have a second?",
threads = [
ConversationThread(
posts = [
Post(
body = ItemBody(
content_type = BodyType.Html,
content = "This is urgent!",
),
extensions = [
OpenTypeExtension(
odata_type = "microsoft.graph.openTypeExtension",
extension_name = "Com.Contoso.Benefits",
additional_data = {
"company_name" : "Contoso",
"expiration_date" : "2016-08-03T11:00:00.000Z",
"top_picks" : [
"Employees only",
"Add spouse or guest",
"Add family",
],
}
),
],
),
],
),
],
)
result = await graph_client.groups.by_group_id('group-id').conversations.post(request_body)
Réponse 5
Voici la réponse pour le cinquième exemple qui contient la nouvelle conversation et l’ID d’un thread. Ce nouveau thread contient un billet créé automatiquement, qui contient à son tour la nouvelle extension.
Remarque : l’objet de réponse affiché ci-après peut être raccourci pour plus de lisibilité.
Pour obtenir la nouvelle extension, commencez par obtenir toutes les publications de ce thread, et au départ, il ne devrait y en avoir qu’une seule. Ensuite, appliquez l’ID de publication et le nom Com.Contoso.Benefits de l’extension pour obtenir l’extension.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#groups('37df2ff0-0de0-4c33-8aee-75289364aef6')/conversations/$entity",
"id": "AAQkADJToRlbJ5Mg7TFM7H-j3Y=",
"threads": [
{
"id": "AAQkADJDtMUzsf_PdhAAswJOhGVsnkyDtMUzsf_Pdg=="
}
]
}
Demande 6
L’exemple suivant montre comment créer une extension sur un driveItem existant.
POST https://graph.microsoft.com/beta/drive/items/01FWCEC553UUOHTOAGBVE2IXBQTIZY3JZQ/extensions
Content-type: application/json
{
"extensionName": "myCustomExtension",
"myCustomString": "Contoso data",
"myCustomBool": false
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new Extension
{
AdditionalData = new Dictionary<string, object>
{
{
"extensionName" , "myCustomExtension"
},
{
"myCustomString" , "Contoso data"
},
{
"myCustomBool" , false
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Drives["{drive-id}"].Items["{driveItem-id}"].Extensions.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"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewExtension()
additionalData := map[string]interface{}{
"extensionName" : "myCustomExtension",
"myCustomString" : "Contoso data",
myCustomBool := false
requestBody.SetMyCustomBool(&myCustomBool)
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
extensions, err := graphClient.Drives().ByDriveId("drive-id").Items().ByDriveItemId("driveItem-id").Extensions().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Extension extension = new Extension();
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("extensionName", "myCustomExtension");
additionalData.put("myCustomString", "Contoso data");
additionalData.put("myCustomBool", false);
extension.setAdditionalData(additionalData);
Extension result = graphClient.drives().byDriveId("{drive-id}").items().byDriveItemId("{driveItem-id}").extensions().post(extension);
const options = {
authProvider,
};
const client = Client.init(options);
const extension = {
extensionName: 'myCustomExtension',
myCustomString: 'Contoso data',
myCustomBool: false
};
await client.api('/drive/items/01FWCEC553UUOHTOAGBVE2IXBQTIZY3JZQ/extensions')
.version('beta')
.post(extension);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\Extension;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Extension();
$additionalData = [
'extensionName' => 'myCustomExtension',
'myCustomString' => 'Contoso data',
'myCustomBool' => false,
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->drives()->byDriveId('drive-id')->items()->byDriveItemId('driveItem-id')->extensions()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Files
$params = @{
extensionName = "myCustomExtension"
myCustomString = "Contoso data"
myCustomBool = $false
}
New-MgBetaDriveItemExtension -DriveId $driveId -DriveItemId $driveItemId -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.extension import Extension
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Extension(
additional_data = {
"extension_name" : "myCustomExtension",
"my_custom_string" : "Contoso data",
"my_custom_bool" : False,
}
)
result = await graph_client.drives.by_drive_id('drive-id').items.by_drive_item_id('driveItem-id').extensions.post(request_body)
Réponse 6
L’exemple suivant montre la réponse, y compris les propriétés suivantes pour la nouvelle extension :
- Propriété id avec le nom complet.
- La propriété par défaut extensionName spécifiée dans la demande.
- Les données personnalisées spécifiées dans la requête sont stockées sous la forme de deux propriétés personnalisées.
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
{
"id": "myCustomExtension",
"extensionName": "myCustomExtension",
"myCustomString": "Contoso data",
"myCustomBool": false
}
Demande 7
L’exemple suivant montre comment créer un driveItem et une extension ouverte pour l’élément driveItem.
POST https://graph.microsoft.com/beta/drive/items/01FWCEC553UUOHTOAGBVE2IXBQTIZY3JZQ/children
Content-type: application/json
{
"name": "New Item",
"@microsoft.graph.conflictBehavior": "rename",
"extensions": [
{
"extensionName": "myCustomExtension",
"myCustomString": "Contoso data",
"myCustomBool": false
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new DriveItem
{
Name = "New Item",
Extensions = new List<Extension>
{
new Extension
{
AdditionalData = new Dictionary<string, object>
{
{
"extensionName" , "myCustomExtension"
},
{
"myCustomString" , "Contoso data"
},
{
"myCustomBool" , false
},
},
},
},
AdditionalData = new Dictionary<string, object>
{
{
"@microsoft.graph.conflictBehavior" , "rename"
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Drives["{drive-id}"].Items["{driveItem-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"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewDriveItem()
name := "New Item"
requestBody.SetName(&name)
extension := graphmodels.NewExtension()
additionalData := map[string]interface{}{
"extensionName" : "myCustomExtension",
"myCustomString" : "Contoso data",
myCustomBool := false
extension.SetMyCustomBool(&myCustomBool)
}
extension.SetAdditionalData(additionalData)
extensions := []graphmodels.Extensionable {
extension,
}
requestBody.SetExtensions(extensions)
additionalData := map[string]interface{}{
"@microsoft.graph.conflictBehavior" : "rename",
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
children, err := graphClient.Drives().ByDriveId("drive-id").Items().ByDriveItemId("driveItem-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);
DriveItem driveItem = new DriveItem();
driveItem.setName("New Item");
LinkedList<Extension> extensions = new LinkedList<Extension>();
Extension extension = new Extension();
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("extensionName", "myCustomExtension");
additionalData.put("myCustomString", "Contoso data");
additionalData.put("myCustomBool", false);
extension.setAdditionalData(additionalData);
extensions.add(extension);
driveItem.setExtensions(extensions);
HashMap<String, Object> additionalData1 = new HashMap<String, Object>();
additionalData1.put("@microsoft.graph.conflictBehavior", "rename");
driveItem.setAdditionalData(additionalData1);
DriveItem result = graphClient.drives().byDriveId("{drive-id}").items().byDriveItemId("{driveItem-id}").children().post(driveItem);
const options = {
authProvider,
};
const client = Client.init(options);
const driveItem = {
name: 'New Item',
'@microsoft.graph.conflictBehavior': 'rename',
extensions: [
{
extensionName: 'myCustomExtension',
myCustomString: 'Contoso data',
myCustomBool: false
}
]
};
await client.api('/drive/items/01FWCEC553UUOHTOAGBVE2IXBQTIZY3JZQ/children')
.version('beta')
.post(driveItem);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\DriveItem;
use Microsoft\Graph\Beta\Generated\Models\Extension;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new DriveItem();
$requestBody->setName('New Item');
$extensionsExtension1 = new Extension();
$additionalData = [
'extensionName' => 'myCustomExtension',
'myCustomString' => 'Contoso data',
'myCustomBool' => false,
];
$extensionsExtension1->setAdditionalData($additionalData);
$extensionsArray []= $extensionsExtension1;
$requestBody->setExtensions($extensionsArray);
$additionalData = [
'@microsoft.graph.conflictBehavior' => 'rename',
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->drives()->byDriveId('drive-id')->items()->byDriveItemId('driveItem-id')->children()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Files
$params = @{
name = "New Item"
"@microsoft.graph.conflictBehavior" = "rename"
extensions = @(
@{
extensionName = "myCustomExtension"
myCustomString = "Contoso data"
myCustomBool = $false
}
)
}
New-MgBetaDriveItemChild -DriveId $driveId -DriveItemId $driveItemId -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.drive_item import DriveItem
from msgraph_beta.generated.models.extension import Extension
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = DriveItem(
name = "New Item",
extensions = [
Extension(
additional_data = {
"extension_name" : "myCustomExtension",
"my_custom_string" : "Contoso data",
"my_custom_bool" : False,
}
),
],
additional_data = {
"@microsoft_graph_conflict_behavior" : "rename",
}
)
result = await graph_client.drives.by_drive_id('drive-id').items.by_drive_item_id('driveItem-id').children.post(request_body)
Réponse 7
L’exemple suivant montre la réponse, y compris les propriétés du nouvel objet driveItem et les éléments suivants pour la nouvelle extension :
- Propriété id avec le nom complet.
- La propriété par défaut extensionName spécifiée dans la demande.
- Les données personnalisées spécifiées dans la requête sont stockées sous la forme de deux propriétés personnalisées.
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
{
"id": "ACEA49D1-1444-45A9-A1CB-68B1B28AE491",
"createdDateTime": "2022-08-30T22:55:29Z",
"name": "New Folder",
"extensions": [
{
"id": "myCustomExtension",
"extensionName": "myCustomExtension",
"myCustomString": "Contoso data",
"myCustomBool": false
}
]
}
Demande 8
L’exemple suivant montre comment créer une extension ouverte sur un site existant.
POST https://graph.microsoft.com/beta/sites/8f52f9ad-4f4f-4739-b682-7c0283207937/extensions
{
"extensionName": "myCustomExtension",
"myCustomString": "Contoso data",
"myCustomBool": false
}
Réponse 8
L’exemple suivant montre la réponse, y compris les propriétés de la nouvelle extension :
- Propriété id avec le nom complet.
- La propriété par défaut extensionName spécifiée dans la demande.
- Les données personnalisées spécifiées dans la requête sont stockées sous la forme de deux propriétés personnalisées.
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
{
"id": "myCustomExtension",
"extensionName": "myCustomExtension",
"myCustomString": "Contoso data",
"myCustomBool": false
}