Create open extension
Makale
06/01/2022
Okumak için 16 dakika
11 katılımcı
Bu makalede
Namespace: microsoft.graph
Create an open extension (openTypeExtension object) and add custom properties in a new or existing instance of a resource.
The table in the Permissions section lists the resources that support open extensions.
Note: If you're creating open extensions on Outlook resources, see Outlook-specific considerations in openTypeExtension resource type .
Permissions
Depending on the resource you're creating the extension in and the permission type (delegated or application) requested, the permission specified in the following table is the least privileged required to call this API. To learn more, including taking caution before choosing more privileged permissions, search for the following permissions in Permissions .
Supported resource
Delegated (work or school account)
Delegated (personal Microsoft account)
Application
device
Directory.AccessAsUser.All
Not supported
Device.ReadWrite.All
event
Calendars.ReadWrite
Calendars.ReadWrite
Calendars.ReadWrite
group
Group.ReadWrite.All
Not supported
Group.ReadWrite.All
group event
Group.ReadWrite.All
Not supported
Not supported
group post
Group.ReadWrite.All
Not supported
Group.ReadWrite.All
message
Mail.ReadWrite
Mail.ReadWrite
Mail.ReadWrite
organization
Organization.ReadWrite.All
Not supported
Organization.ReadWrite.All
personal contact
Contacts.ReadWrite
Contacts.ReadWrite
Contacts.ReadWrite
todoTask
Tasks.ReadWrite
Tasks.ReadWrite
Tasks.ReadWrite.All
todoTaskList
Tasks.ReadWrite
Tasks.ReadWrite
Tasks.ReadWrite.All
user
User.ReadWrite
User.ReadWrite
User.ReadWrite.All
HTTP request
Create an extension in a new resource instance
Use the same REST request that you use to create the instance.
POST /users/{id|userPrincipalName}/events
POST /users/{id|userPrincipalName}/messages
POST /groups/{id}/events
POST /groups/{id}/threads/{id}/posts/{id}/reply
POST /users/{id|userPrincipalName}/contacts
POST /users/{id|userPrincipalName}/todo/lists/{id}/tasks
POST /users/{id|userPrincipalName}/todo/lists
Note: This syntax shows some common ways to create the supported resource instances. All other POST syntaxes
that allows you to create these resource instances supports creating open extensions in them in a similar way.
See the Request body section about including the properties of the new resource instance and the extension in the request body.
Create an extension in an existing resource instance
Identify the resource instance in the request and do a POST
to the extensions navigation property.
POST /devices/{id}/extensions
POST /users/{id|userPrincipalName}/events/{id}/extensions
POST /groups/{id}/extensions
POST /groups/{id}/events/{id}/extensions
POST /groups/{id}/threads/{id}/posts/{id}/extensions
POST /users/{id|userPrincipalName}/messages/{id}/extensions
POST /organization/{id}/extensions
POST /users/{id|userPrincipalName}/contacts/{id}/extensions
POST /users/{id|userPrincipalName}/extensions
POST /users/{id|userPrincipalName}/todo/lists/{id}/tasks/{id}/extensions
POST /users/{id|userPrincipalName}/todo/lists/{id}/extensions
Note: This syntax shows some common ways to identify a resource instance, in order to create an
extension in it. All other syntaxes that allows you to identify these resource instances supports creating open extensions in them in a similar way.
See the Request body section about including the extension in the request body.
Path parameters
Parameter
Type
Description
id
string
A unique identifier for an object in the corresponding collection. Required.
Name
Value
Authorization
Bearer {token}. Required.
Content-Type
application/json
Request body
Provide a JSON body of an openTypeExtension , with the following required
name-value pairs, and any additional custom data. The data in the JSON payload can be primitive types, or arrays of
primitive types.
Name
Value
@odata.type
microsoft.graph.openTypeExtension
extensionName
%unique_string%
When creating an extension in a new resource instance, in addition to the
new openTypeExtension object, provide a JSON representation of the relevant properties to create such a resource instance.
Response
Response code
Depending on the operation, the response code can be 201 Created
or 202 Accepted
.
When you create an extension using the same operation that you use to create a resource instance, the operation returns the same response code that it returns when you use the operation to create the resource instance without the extension.
Refer to the corresponding topics for creating the instance, as listed above .
Response body
Scenario
Resource
Response body
Creating an extension while explicitly creating a new resource instance
contact , event , message
Includes the new instance expanded with the openTypeExtension object.
Creating an extension while implicitly creating a resource instance
post
The response includes only a response code but not a response body.
Creating an extension in an existing resource instance
All supported resources
Includes the openTypeExtension object.
Example
Request 1
The first example creates a message and an extension in the same call. The request body includes the following:
POST https://graph.microsoft.com/v1.0/me/messages
{
"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
}
]
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var message = 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 MessageExtensionsCollectionPage()
{
new OpenTypeExtension
{
ExtensionName = "Com.Contoso.Referral",
AdditionalData = new Dictionary<string, object>()
{
{"companyName", "Wingtip Toys"},
{"expirationDate", "2015-12-30T11:00:00Z"},
{"dealValue", "10000"}
}
}
}
};
await graphClient.Me.Messages
.Request()
.AddAsync(message);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
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')
.post(message);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/messages"]]];
[urlRequest setHTTPMethod:@"POST"];
MSGraphMessage *message = [[MSGraphMessage alloc] init];
[message setSubject:@"Annual review"];
MSGraphItemBody *body = [[MSGraphItemBody alloc] init];
[body setContentType: [MSGraphBodyType html]];
[body setContent:@"You should be proud!"];
[message setBody:body];
NSMutableArray *toRecipientsList = [[NSMutableArray alloc] init];
MSGraphRecipient *toRecipients = [[MSGraphRecipient alloc] init];
MSGraphEmailAddress *emailAddress = [[MSGraphEmailAddress alloc] init];
[emailAddress setAddress:@"rufus@contoso.com"];
[toRecipients setEmailAddress:emailAddress];
[toRecipientsList addObject: toRecipients];
[message setToRecipients:toRecipientsList];
NSMutableArray *extensionsList = [[NSMutableArray alloc] init];
MSGraphExtension *extensions = [[MSGraphExtension alloc] init];
[extensions setExtensionName:@"Com.Contoso.Referral"];
[extensions setCompanyName:@"Wingtip Toys"];
[extensions setExpirationDate: "2015-12-30T11:00:00Z"];
[extensions setDealValue: 10000];
[extensionsList addObject: extensions];
[message setExtensions:extensionsList];
NSError *error;
NSData *messageData = [message getSerializedDataWithError:&error];
[urlRequest setHTTPBody:messageData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewMessage()
subject := "Annual review"
requestBody.SetSubject(&subject)
body := msgraphsdk.NewItemBody()
requestBody.SetBody(body)
contentType := "HTML"
body.SetContentType(&contentType)
content := "You should be proud!"
body.SetContent(&content)
requestBody.SetToRecipients( []Recipient {
msgraphsdk.NewRecipient(),
emailAddress := msgraphsdk.NewEmailAddress()
SetEmailAddress(emailAddress)
address := "rufus@contoso.com"
emailAddress.SetAddress(&address)
}
requestBody.SetExtensions( []Extension {
msgraphsdk.NewExtension(),
SetAdditionalData(map[string]interface{}{
"@odata.type": "microsoft.graph.openTypeExtension",
"extensionName": "Com.Contoso.Referral",
"companyName": "Wingtip Toys",
"expirationDate": "2015-12-30T11:00:00.000Z",
"dealValue": ,
}
}
result, err := graphClient.Me().Messages().Post(requestBody)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Response 1
Here is the response for the first example. The response body includes properties of the new message,
and the following for the new extension:
The id property with the fully qualified name of microsoft.graph.openTypeExtension.Com.Contoso.Referral
.
The default property extensionName specified in the request.
The custom data specified in the request stored as 3 custom properties.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Me/messages/$entity",
"@odata.id": "https://graph.microsoft.com/v1.0/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/v1.0/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
}
]
}
Request 2
The second example creates an extension in the specified message. The request body includes the following for the
extension:
The type microsoft.graph.openTypeExtension
.
The extension name "Com.Contoso.Referral".
Additional data to be stored as 3 custom properties in the JSON payload: companyName
, dealValue
, and expirationDate
.
POST https://graph.microsoft.com/v1.0/me/messages/AAMkAGE1M2IyNGNmLTI5MTktNDUyZi1iOTVl===/extensions
{
"@odata.type" : "microsoft.graph.openTypeExtension",
"extensionName" : "Com.Contoso.Referral",
"companyName" : "Wingtip Toys",
"dealValue" : 500050,
"expirationDate" : "2015-12-03T10:00:00.000Z"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var extension = new OpenTypeExtension
{
ExtensionName = "Com.Contoso.Referral",
AdditionalData = new Dictionary<string, object>()
{
{"companyName", "Wingtip Toys"},
{"dealValue", "500050"},
{"expirationDate", "2015-12-03T10:00:00Z"}
}
};
await graphClient.Me.Messages["{message-id}"].Extensions
.Request()
.AddAsync(extension);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
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')
.post(extension);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/messages/AAMkAGE1M2IyNGNmLTI5MTktNDUyZi1iOTVl===/extensions"]]];
[urlRequest setHTTPMethod:@"POST"];
MSGraphExtension *extension = [[MSGraphExtension alloc] init];
[extension setExtensionName:@"Com.Contoso.Referral"];
[extension setCompanyName:@"Wingtip Toys"];
[extension setDealValue: 500050];
[extension setExpirationDate: "2015-12-03T10:00:00Z"];
NSError *error;
NSData *extensionData = [extension getSerializedDataWithError:&error];
[urlRequest setHTTPBody:extensionData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewExtension()
requestBody.SetAdditionalData(map[string]interface{}{
"@odata.type": "microsoft.graph.openTypeExtension",
"extensionName": "Com.Contoso.Referral",
"companyName": "Wingtip Toys",
"dealValue": ,
"expirationDate": "2015-12-03T10:00:00.000Z",
}
messageId := "message-id"
result, err := graphClient.Me().MessagesById(&messageId).Extensions().Post(requestBody)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Response 2
Here is the response for the second example. The response body includes the following for the new extension:
The default property extensionName .
The id property with the fully qualified name of microsoft.graph.openTypeExtension.Com.Contoso.Referral
.
The custom data to be stored.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Me/messages('AAMkAGE1M2IyNGNmLTI5MTktNDUyZi1iOTVl===')/extensions/$entity",
"@odata.type": "#microsoft.graph.openTypeExtension",
"@odata.id": "https://graph.microsoft.com/v1.0/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"
}
Request 3
The third example creates an extension in the specified group event. The request body includes the following for the
extension:
The type microsoft.graph.openTypeExtension
.
The extension name "Com.Contoso.Deal".
Additional data to be stored as 3 custom properties in the JSON payload: companyName
, dealValue
, and expirationDate
.
POST https://graph.microsoft.com/v1.0/groups/f5480dfd-7d77-4d0b-ba2e-3391953cc74a/events/AAMkADVl17IsAAA=/extensions
{
"@odata.type" : "microsoft.graph.openTypeExtension",
"extensionName" : "Com.Contoso.Deal",
"companyName" : "Alpine Skis",
"dealValue" : 1010100,
"expirationDate" : "2015-07-03T13:04:00.000Z"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var extension = new OpenTypeExtension
{
ExtensionName = "Com.Contoso.Deal",
AdditionalData = new Dictionary<string, object>()
{
{"companyName", "Alpine Skis"},
{"dealValue", "1010100"},
{"expirationDate", "2015-07-03T13:04:00Z"}
}
};
await graphClient.Groups["{group-id}"].Events["{event-id}"].Extensions
.Request()
.AddAsync(extension);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
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')
.post(extension);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/groups/f5480dfd-7d77-4d0b-ba2e-3391953cc74a/events/AAMkADVl17IsAAA=/extensions"]]];
[urlRequest setHTTPMethod:@"POST"];
MSGraphExtension *extension = [[MSGraphExtension alloc] init];
[extension setExtensionName:@"Com.Contoso.Deal"];
[extension setCompanyName:@"Alpine Skis"];
[extension setDealValue: 1010100];
[extension setExpirationDate: "2015-07-03T13:04:00Z"];
NSError *error;
NSData *extensionData = [extension getSerializedDataWithError:&error];
[urlRequest setHTTPBody:extensionData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewExtension()
requestBody.SetAdditionalData(map[string]interface{}{
"@odata.type": "microsoft.graph.openTypeExtension",
"extensionName": "Com.Contoso.Deal",
"companyName": "Alpine Skis",
"dealValue": ,
"expirationDate": "2015-07-03T13:04:00.000Z",
}
groupId := "group-id"
eventId := "event-id"
result, err := graphClient.GroupsById(&groupId).EventsById(&eventId).Extensions().Post(requestBody)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Response 3
Here is the response from the third example request.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$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"
}
Request 4
The fourth example creates an extension in a new group post, using the same reply action call to an existing group post. The reply action
creates a new post, and a new extension embedded in the post. The request body includes a post property, which in turn contains
the body of the new post, and the following data for the new extension:
The type microsoft.graph.openTypeExtension
.
The extension name "Com.Contoso.HR".
Additional data to be stored as 3 custom properties in the JSON payload: companyName
, expirationDate
, and the array of strings topPicks
.
POST https://graph.microsoft.com/v1.0/groups/37df2ff0-0de0-4c33-8aee-75289364aef6/threads/AAQkADJizZJpEWwqDHsEpV_KA==/posts/AAMkADJiUg96QZUkA-ICwMubAAC1heiSAAA=/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"
]
}
]
}
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var 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 PostExtensionsCollectionPage()
{
new OpenTypeExtension
{
ExtensionName = "Com.Contoso.HR",
AdditionalData = new Dictionary<string, object>()
{
{"companyName", "Contoso"},
{"expirationDate", "2015-07-03T13:04:00Z"},
{"topPicks", "[\"Employees only\",\"Add spouse or guest\",\"Add family\"]"}
}
}
}
};
await graphClient.Groups["{group-id}"].Threads["{conversationThread-id}"].Posts["{post-id}"]
.Reply(post)
.Request()
.PostAsync();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
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')
.post(reply);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/groups/37df2ff0-0de0-4c33-8aee-75289364aef6/threads/AAQkADJizZJpEWwqDHsEpV_KA==/posts/AAMkADJiUg96QZUkA-ICwMubAAC1heiSAAA=/reply"]]];
[urlRequest setHTTPMethod:@"POST"];
NSMutableDictionary *payloadDictionary = [[NSMutableDictionary alloc] init];
MSGraphPost *post = [[MSGraphPost alloc] init];
MSGraphItemBody *body = [[MSGraphItemBody alloc] init];
[body setContentType: [MSGraphBodyType html]];
[body setContent:@"<html><body><div><div><div><div>When and where? </div></div></div></div></body></html>"];
[post setBody:body];
NSMutableArray *extensionsList = [[NSMutableArray alloc] init];
MSGraphExtension *extensions = [[MSGraphExtension alloc] init];
[extensions setExtensionName:@"Com.Contoso.HR"];
[extensions setCompanyName:@"Contoso"];
[extensions setExpirationDate: "2015-07-03T13:04:00Z"];
NSMutableArray *topPicksList = [[NSMutableArray alloc] init];
[topPicksList addObject: @"Employees only"];
[topPicksList addObject: @"Add spouse or guest"];
[topPicksList addObject: @"Add family"];
[extensions setTopPicks:topPicksList];
[extensionsList addObject: extensions];
[post setExtensions:extensionsList];
payloadDictionary[@"post"] = post;
NSData *data = [NSJSONSerialization dataWithJSONObject:payloadDictionary options:kNilOptions error:&error];
[urlRequest setHTTPBody:data];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewPostRequestBody()
post := msgraphsdk.NewPost()
requestBody.SetPost(post)
body := msgraphsdk.NewItemBody()
post.SetBody(body)
contentType := "html"
body.SetContentType(&contentType)
content := "<html><body><div><div><div><div>When and where? </div></div></div></div></body></html>"
body.SetContent(&content)
post.SetExtensions( []Extension {
msgraphsdk.NewExtension(),
SetAdditionalData(map[string]interface{}{
"@odata.type": "microsoft.graph.openTypeExtension",
"extensionName": "Com.Contoso.HR",
"companyName": "Contoso",
"expirationDate": "2015-07-03T13:04:00.000Z",
"topPicks": []String {
"Employees only",
"Add spouse or guest",
"Add family",
}
}
}
groupId := "group-id"
conversationThreadId := "conversationThread-id"
postId := "post-id"
graphClient.GroupsById(&groupId).ThreadsById(&conversationThreadId).PostsById(&postId).Reply(group-id, conversationThread-id, post-id).Post(requestBody)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Response 4
Here is the response from the fourth example. Successfully creating an extension in a new group post results in only the
HTTP 202 response code.
HTTP/1.1 202 Accepted
Content-type: text/plain
Content-Length: 0
Request 5
The fifth example creates an extension in a new group post using the same POST operation to create a conversation. The POST operation
creates a new conversation, thread and post, and a new extension embedded in the post. The request body includes the
Topic and Threads properties, and a child post object for the new conversation. The post object
in turn contains the body of the new post, and the following data for the extension:
The type microsoft.graph.openTypeExtension
.
The extension name "Com.Contoso.HR".
Additional data to be stored as 3 custom properties in the JSON payload: companyName
, expirationDate
, and the array of strings topPicks
.
POST https://graph.microsoft.com/v1.0/groups/37df2ff0-0de0-4c33-8aee-75289364aef6/conversations
{
"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"
]
}
]
}
]
}
]
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var conversation = new Conversation
{
Topic = "Does anyone have a second?",
Threads = new ConversationThreadsCollectionPage()
{
new ConversationThread
{
Posts = new ConversationThreadPostsCollectionPage()
{
new Post
{
Body = new ItemBody
{
ContentType = BodyType.Html,
Content = "This is urgent!"
},
Extensions = new PostExtensionsCollectionPage()
{
new OpenTypeExtension
{
ExtensionName = "Com.Contoso.Benefits",
AdditionalData = new Dictionary<string, object>()
{
{"companyName", "Contoso"},
{"expirationDate", "2016-08-03T11:00:00Z"},
{"topPicks", "[\"Employees only\",\"Add spouse or guest\",\"Add family\"]"}
}
}
}
}
}
}
}
};
await graphClient.Groups["{group-id}"].Conversations
.Request()
.AddAsync(conversation);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
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')
.post(conversation);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/groups/37df2ff0-0de0-4c33-8aee-75289364aef6/conversations"]]];
[urlRequest setHTTPMethod:@"POST"];
MSGraphConversation *conversation = [[MSGraphConversation alloc] init];
[conversation setTopic:@"Does anyone have a second?"];
NSMutableArray *ThreadsList = [[NSMutableArray alloc] init];
MSGraphConversationThread *Threads = [[MSGraphConversationThread alloc] init];
NSMutableArray *PostsList = [[NSMutableArray alloc] init];
MSGraphPost *Posts = [[MSGraphPost alloc] init];
MSGraphItemBody *Body = [[MSGraphItemBody alloc] init];
[Body setContentType: [MSGraphBodyType html]];
[Body setContent:@"This is urgent!"];
[Posts setBody:Body];
NSMutableArray *ExtensionsList = [[NSMutableArray alloc] init];
MSGraphExtension *Extensions = [[MSGraphExtension alloc] init];
[Extensions setExtensionName:@"Com.Contoso.Benefits"];
[Extensions setCompanyName:@"Contoso"];
[Extensions setExpirationDate: "2016-08-03T11:00:00Z"];
NSMutableArray *topPicksList = [[NSMutableArray alloc] init];
[topPicksList addObject: @"Employees only"];
[topPicksList addObject: @"Add spouse or guest"];
[topPicksList addObject: @"Add family"];
[Extensions setTopPicks:topPicksList];
[ExtensionsList addObject: Extensions];
[Posts setExtensions:ExtensionsList];
[PostsList addObject: Posts];
[Threads setPosts:PostsList];
[ThreadsList addObject: Threads];
[conversation setThreads:ThreadsList];
NSError *error;
NSData *conversationData = [conversation getSerializedDataWithError:&error];
[urlRequest setHTTPBody:conversationData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewConversation()
topic := "Does anyone have a second?"
requestBody.SetTopic(&topic)
requestBody.SetThreads( []ConversationThread {
msgraphsdk.NewConversationThread(),
SetPosts( []Post {
msgraphsdk.NewPost(),
body := msgraphsdk.NewItemBody()
SetBody(body)
contentType := "HTML"
body.SetContentType(&contentType)
content := "This is urgent!"
body.SetContent(&content)
SetExtensions( []Extension {
msgraphsdk.NewExtension(),
SetAdditionalData(map[string]interface{}{
"@odata.type": "microsoft.graph.openTypeExtension",
"extensionName": "Com.Contoso.Benefits",
"companyName": "Contoso",
"expirationDate": "2016-08-03T11:00:00.000Z",
"topPicks": []String {
"Employees only",
"Add spouse or guest",
"Add family",
}
}
}
}
}
groupId := "group-id"
result, err := graphClient.GroupsById(&groupId).Conversations().Post(requestBody)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Response 5
Here is the response from the fifth example which contains the new conversation and a thread ID. This new thread contains an automatically
created post, which in turn contains the new extension.
Note: The response object shown here might be shortened for readability.
To get the new extension, first get all the posts in this
thread, and initially there should be only one. Then apply the post ID and the extension name Com.Contoso.Benefits
to
get the extension .
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups('37df2ff0-0de0-4c33-8aee-75289364aef6')/conversations/$entity",
"id": "AAQkADJToRlbJ5Mg7TFM7H-j3Y=",
"threads": [
{
"id": "AAQkADJDtMUzsf_PdhAAswJOhGVsnkyDtMUzsf_Pdg=="
}
]
}