次の例は、アクティビティ フィード通知を複数のユーザーに一括で送信する方法を示しています。 この例では、保留中の財務承認要求について複数の利害関係者に通知します。
POST https://graph.microsoft.com/beta/teamwork/sendActivityNotificationToRecipients
Content-Type: application/json
{
"topic": {
"source": "entityUrl",
"value": "https://graph.microsoft.com/beta/appCatalogs/teamsApps/{teamsAppId}"
},
"activityType": "pendingFinanceApprovalRequests",
"previewText": {
"content": "Internal spending team has a pending finance approval requests"
},
"recipients": [
{
"@odata.type": "microsoft.graph.aadUserNotificationRecipient",
"userId": "569363e2-4e49-4661-87f2-16f245c5d66a"
},
{
"@odata.type": "microsoft.graph.aadUserNotificationRecipient",
"userId": "ab88234e-0874-477c-9638-d144296ed04f"
},
{
"@odata.type": "microsoft.graph.aadUserNotificationRecipient",
"userId": "01c64f53-69aa-42c7-9b7f-9f75195d6bfc"
}
],
"templateParameters": [
{
"name": "pendingRequestCount",
"value": "5"
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Teamwork.SendActivityNotificationToRecipients;
using Microsoft.Graph.Beta.Models;
var requestBody = new SendActivityNotificationToRecipientsPostRequestBody
{
Topic = new TeamworkActivityTopic
{
Source = TeamworkActivityTopicSource.EntityUrl,
Value = "https://graph.microsoft.com/beta/appCatalogs/teamsApps/{teamsAppId}",
},
ActivityType = "pendingFinanceApprovalRequests",
PreviewText = new ItemBody
{
Content = "Internal spending team has a pending finance approval requests",
},
Recipients = new List<TeamworkNotificationRecipient>
{
new AadUserNotificationRecipient
{
OdataType = "microsoft.graph.aadUserNotificationRecipient",
UserId = "569363e2-4e49-4661-87f2-16f245c5d66a",
},
new AadUserNotificationRecipient
{
OdataType = "microsoft.graph.aadUserNotificationRecipient",
UserId = "ab88234e-0874-477c-9638-d144296ed04f",
},
new AadUserNotificationRecipient
{
OdataType = "microsoft.graph.aadUserNotificationRecipient",
UserId = "01c64f53-69aa-42c7-9b7f-9f75195d6bfc",
},
},
TemplateParameters = new List<KeyValuePair>
{
new KeyValuePair
{
Name = "pendingRequestCount",
Value = "5",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Teamwork.SendActivityNotificationToRecipients.PostAsync(requestBody);
mgc-beta teamwork send-activity-notification-to-recipients post --body '{\
"topic": {\
"source": "entityUrl",\
"value": "https://graph.microsoft.com/beta/appCatalogs/teamsApps/{teamsAppId}"\
},\
"activityType": "pendingFinanceApprovalRequests",\
"previewText": {\
"content": "Internal spending team has a pending finance approval requests"\
},\
"recipients": [\
{\
"@odata.type": "microsoft.graph.aadUserNotificationRecipient",\
"userId": "569363e2-4e49-4661-87f2-16f245c5d66a"\
},\
{\
"@odata.type": "microsoft.graph.aadUserNotificationRecipient",\
"userId": "ab88234e-0874-477c-9638-d144296ed04f"\
},\
{\
"@odata.type": "microsoft.graph.aadUserNotificationRecipient",\
"userId": "01c64f53-69aa-42c7-9b7f-9f75195d6bfc"\
}\
],\
"templateParameters": [\
{\
"name": "pendingRequestCount",\
"value": "5"\
}\
]\
}\
'
// 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"
graphteamwork "github.com/microsoftgraph/msgraph-beta-sdk-go/teamwork"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphteamwork.NewSendActivityNotificationToRecipientsPostRequestBody()
topic := graphmodels.NewTeamworkActivityTopic()
source := graphmodels.ENTITYURL_TEAMWORKACTIVITYTOPICSOURCE
topic.SetSource(&source)
value := "https://graph.microsoft.com/beta/appCatalogs/teamsApps/{teamsAppId}"
topic.SetValue(&value)
requestBody.SetTopic(topic)
activityType := "pendingFinanceApprovalRequests"
requestBody.SetActivityType(&activityType)
previewText := graphmodels.NewItemBody()
content := "Internal spending team has a pending finance approval requests"
previewText.SetContent(&content)
requestBody.SetPreviewText(previewText)
teamworkNotificationRecipient := graphmodels.NewAadUserNotificationRecipient()
userId := "569363e2-4e49-4661-87f2-16f245c5d66a"
teamworkNotificationRecipient.SetUserId(&userId)
teamworkNotificationRecipient1 := graphmodels.NewAadUserNotificationRecipient()
userId := "ab88234e-0874-477c-9638-d144296ed04f"
teamworkNotificationRecipient1.SetUserId(&userId)
teamworkNotificationRecipient2 := graphmodels.NewAadUserNotificationRecipient()
userId := "01c64f53-69aa-42c7-9b7f-9f75195d6bfc"
teamworkNotificationRecipient2.SetUserId(&userId)
recipients := []graphmodels.TeamworkNotificationRecipientable {
teamworkNotificationRecipient,
teamworkNotificationRecipient1,
teamworkNotificationRecipient2,
}
requestBody.SetRecipients(recipients)
keyValuePair := graphmodels.NewKeyValuePair()
name := "pendingRequestCount"
keyValuePair.SetName(&name)
value := "5"
keyValuePair.SetValue(&value)
templateParameters := []graphmodels.KeyValuePairable {
keyValuePair,
}
requestBody.SetTemplateParameters(templateParameters)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Teamwork().SendActivityNotificationToRecipients().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.teamwork.sendactivitynotificationtorecipients.SendActivityNotificationToRecipientsPostRequestBody sendActivityNotificationToRecipientsPostRequestBody = new com.microsoft.graph.beta.teamwork.sendactivitynotificationtorecipients.SendActivityNotificationToRecipientsPostRequestBody();
TeamworkActivityTopic topic = new TeamworkActivityTopic();
topic.setSource(TeamworkActivityTopicSource.EntityUrl);
topic.setValue("https://graph.microsoft.com/beta/appCatalogs/teamsApps/{teamsAppId}");
sendActivityNotificationToRecipientsPostRequestBody.setTopic(topic);
sendActivityNotificationToRecipientsPostRequestBody.setActivityType("pendingFinanceApprovalRequests");
ItemBody previewText = new ItemBody();
previewText.setContent("Internal spending team has a pending finance approval requests");
sendActivityNotificationToRecipientsPostRequestBody.setPreviewText(previewText);
LinkedList<TeamworkNotificationRecipient> recipients = new LinkedList<TeamworkNotificationRecipient>();
AadUserNotificationRecipient teamworkNotificationRecipient = new AadUserNotificationRecipient();
teamworkNotificationRecipient.setOdataType("microsoft.graph.aadUserNotificationRecipient");
teamworkNotificationRecipient.setUserId("569363e2-4e49-4661-87f2-16f245c5d66a");
recipients.add(teamworkNotificationRecipient);
AadUserNotificationRecipient teamworkNotificationRecipient1 = new AadUserNotificationRecipient();
teamworkNotificationRecipient1.setOdataType("microsoft.graph.aadUserNotificationRecipient");
teamworkNotificationRecipient1.setUserId("ab88234e-0874-477c-9638-d144296ed04f");
recipients.add(teamworkNotificationRecipient1);
AadUserNotificationRecipient teamworkNotificationRecipient2 = new AadUserNotificationRecipient();
teamworkNotificationRecipient2.setOdataType("microsoft.graph.aadUserNotificationRecipient");
teamworkNotificationRecipient2.setUserId("01c64f53-69aa-42c7-9b7f-9f75195d6bfc");
recipients.add(teamworkNotificationRecipient2);
sendActivityNotificationToRecipientsPostRequestBody.setRecipients(recipients);
LinkedList<KeyValuePair> templateParameters = new LinkedList<KeyValuePair>();
KeyValuePair keyValuePair = new KeyValuePair();
keyValuePair.setName("pendingRequestCount");
keyValuePair.setValue("5");
templateParameters.add(keyValuePair);
sendActivityNotificationToRecipientsPostRequestBody.setTemplateParameters(templateParameters);
graphClient.teamwork().sendActivityNotificationToRecipients().post(sendActivityNotificationToRecipientsPostRequestBody);
const options = {
authProvider,
};
const client = Client.init(options);
const sendActivityNotificationToRecipients = {
topic: {
source: 'entityUrl',
value: 'https://graph.microsoft.com/beta/appCatalogs/teamsApps/{teamsAppId}'
},
activityType: 'pendingFinanceApprovalRequests',
previewText: {
content: 'Internal spending team has a pending finance approval requests'
},
recipients: [
{
'@odata.type': 'microsoft.graph.aadUserNotificationRecipient',
userId: '569363e2-4e49-4661-87f2-16f245c5d66a'
},
{
'@odata.type': 'microsoft.graph.aadUserNotificationRecipient',
userId: 'ab88234e-0874-477c-9638-d144296ed04f'
},
{
'@odata.type': 'microsoft.graph.aadUserNotificationRecipient',
userId: '01c64f53-69aa-42c7-9b7f-9f75195d6bfc'
}
],
templateParameters: [
{
name: 'pendingRequestCount',
value: '5'
}
]
};
await client.api('/teamwork/sendActivityNotificationToRecipients')
.version('beta')
.post(sendActivityNotificationToRecipients);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Teamwork\SendActivityNotificationToRecipients\SendActivityNotificationToRecipientsPostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\TeamworkActivityTopic;
use Microsoft\Graph\Beta\Generated\Models\TeamworkActivityTopicSource;
use Microsoft\Graph\Beta\Generated\Models\ItemBody;
use Microsoft\Graph\Beta\Generated\Models\TeamworkNotificationRecipient;
use Microsoft\Graph\Beta\Generated\Models\AadUserNotificationRecipient;
use Microsoft\Graph\Beta\Generated\Models\KeyValuePair;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new SendActivityNotificationToRecipientsPostRequestBody();
$topic = new TeamworkActivityTopic();
$topic->setSource(new TeamworkActivityTopicSource('entityUrl'));
$topic->setValue('https://graph.microsoft.com/beta/appCatalogs/teamsApps/{teamsAppId}');
$requestBody->setTopic($topic);
$requestBody->setActivityType('pendingFinanceApprovalRequests');
$previewText = new ItemBody();
$previewText->setContent('Internal spending team has a pending finance approval requests');
$requestBody->setPreviewText($previewText);
$recipientsTeamworkNotificationRecipient1 = new AadUserNotificationRecipient();
$recipientsTeamworkNotificationRecipient1->setOdataType('microsoft.graph.aadUserNotificationRecipient');
$recipientsTeamworkNotificationRecipient1->setUserId('569363e2-4e49-4661-87f2-16f245c5d66a');
$recipientsArray []= $recipientsTeamworkNotificationRecipient1;
$recipientsTeamworkNotificationRecipient2 = new AadUserNotificationRecipient();
$recipientsTeamworkNotificationRecipient2->setOdataType('microsoft.graph.aadUserNotificationRecipient');
$recipientsTeamworkNotificationRecipient2->setUserId('ab88234e-0874-477c-9638-d144296ed04f');
$recipientsArray []= $recipientsTeamworkNotificationRecipient2;
$recipientsTeamworkNotificationRecipient3 = new AadUserNotificationRecipient();
$recipientsTeamworkNotificationRecipient3->setOdataType('microsoft.graph.aadUserNotificationRecipient');
$recipientsTeamworkNotificationRecipient3->setUserId('01c64f53-69aa-42c7-9b7f-9f75195d6bfc');
$recipientsArray []= $recipientsTeamworkNotificationRecipient3;
$requestBody->setRecipients($recipientsArray);
$templateParametersKeyValuePair1 = new KeyValuePair();
$templateParametersKeyValuePair1->setName('pendingRequestCount');
$templateParametersKeyValuePair1->setValue('5');
$templateParametersArray []= $templateParametersKeyValuePair1;
$requestBody->setTemplateParameters($templateParametersArray);
$graphServiceClient->teamwork()->sendActivityNotificationToRecipients()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Teams
$params = @{
topic = @{
source = "entityUrl"
value = "https://graph.microsoft.com/beta/appCatalogs/teamsApps/{teamsAppId}"
}
activityType = "pendingFinanceApprovalRequests"
previewText = @{
content = "Internal spending team has a pending finance approval requests"
}
recipients = @(
@{
"@odata.type" = "microsoft.graph.aadUserNotificationRecipient"
userId = "569363e2-4e49-4661-87f2-16f245c5d66a"
}
@{
"@odata.type" = "microsoft.graph.aadUserNotificationRecipient"
userId = "ab88234e-0874-477c-9638-d144296ed04f"
}
@{
"@odata.type" = "microsoft.graph.aadUserNotificationRecipient"
userId = "01c64f53-69aa-42c7-9b7f-9f75195d6bfc"
}
)
templateParameters = @(
@{
name = "pendingRequestCount"
value = "5"
}
)
}
Send-MgBetaTeamworkActivityNotificationToRecipient -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.teamwork.send_activity_notification_to_recipients.send_activity_notification_to_recipients_post_request_body import SendActivityNotificationToRecipientsPostRequestBody
from msgraph_beta.generated.models.teamwork_activity_topic import TeamworkActivityTopic
from msgraph_beta.generated.models.teamwork_activity_topic_source import TeamworkActivityTopicSource
from msgraph_beta.generated.models.item_body import ItemBody
from msgraph_beta.generated.models.teamwork_notification_recipient import TeamworkNotificationRecipient
from msgraph_beta.generated.models.aad_user_notification_recipient import AadUserNotificationRecipient
from msgraph_beta.generated.models.key_value_pair import KeyValuePair
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = SendActivityNotificationToRecipientsPostRequestBody(
topic = TeamworkActivityTopic(
source = TeamworkActivityTopicSource.EntityUrl,
value = "https://graph.microsoft.com/beta/appCatalogs/teamsApps/{teamsAppId}",
),
activity_type = "pendingFinanceApprovalRequests",
preview_text = ItemBody(
content = "Internal spending team has a pending finance approval requests",
),
recipients = [
AadUserNotificationRecipient(
odata_type = "microsoft.graph.aadUserNotificationRecipient",
user_id = "569363e2-4e49-4661-87f2-16f245c5d66a",
),
AadUserNotificationRecipient(
odata_type = "microsoft.graph.aadUserNotificationRecipient",
user_id = "ab88234e-0874-477c-9638-d144296ed04f",
),
AadUserNotificationRecipient(
odata_type = "microsoft.graph.aadUserNotificationRecipient",
user_id = "01c64f53-69aa-42c7-9b7f-9f75195d6bfc",
),
],
template_parameters = [
KeyValuePair(
name = "pendingRequestCount",
value = "5",
),
],
)
await graph_client.teamwork.send_activity_notification_to_recipients.post(request_body)
POST https://graph.microsoft.com/beta/teamwork/sendActivityNotificationToRecipients
Content-Type: application/json
{
"topic": {
"source": "text",
"value": "Deployment Approvals Channel",
"webUrl": "https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000"
},
"activityType": "deploymentApprovalRequired",
"previewText": {
"content": "New deployment requires your approval"
},
"templateParameters": [
{
"name": "deploymentId",
"value": "6788662"
}
],
"recipients": [
{
"@odata.type": "microsoft.graph.aadUserNotificationRecipient",
"userId": "569363e2-4e49-4661-87f2-16f245c5d66a"
},
{
"@odata.type": "microsoft.graph.aadUserNotificationRecipient",
"userId": "ab88234e-0874-477c-9638-d144296ed04f"
},
{
"@odata.type": "microsoft.graph.aadUserNotificationRecipient",
"userId": "01c64f53-69aa-42c7-9b7f-9f75195d6bfc"
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Teamwork.SendActivityNotificationToRecipients;
using Microsoft.Graph.Beta.Models;
var requestBody = new SendActivityNotificationToRecipientsPostRequestBody
{
Topic = new TeamworkActivityTopic
{
Source = TeamworkActivityTopicSource.Text,
Value = "Deployment Approvals Channel",
WebUrl = "https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000",
},
ActivityType = "deploymentApprovalRequired",
PreviewText = new ItemBody
{
Content = "New deployment requires your approval",
},
TemplateParameters = new List<KeyValuePair>
{
new KeyValuePair
{
Name = "deploymentId",
Value = "6788662",
},
},
Recipients = new List<TeamworkNotificationRecipient>
{
new AadUserNotificationRecipient
{
OdataType = "microsoft.graph.aadUserNotificationRecipient",
UserId = "569363e2-4e49-4661-87f2-16f245c5d66a",
},
new AadUserNotificationRecipient
{
OdataType = "microsoft.graph.aadUserNotificationRecipient",
UserId = "ab88234e-0874-477c-9638-d144296ed04f",
},
new AadUserNotificationRecipient
{
OdataType = "microsoft.graph.aadUserNotificationRecipient",
UserId = "01c64f53-69aa-42c7-9b7f-9f75195d6bfc",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Teamwork.SendActivityNotificationToRecipients.PostAsync(requestBody);
mgc-beta teamwork send-activity-notification-to-recipients post --body '{\
"topic": {\
"source": "text",\
"value": "Deployment Approvals Channel",\
"webUrl": "https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000"\
},\
"activityType": "deploymentApprovalRequired",\
"previewText": {\
"content": "New deployment requires your approval"\
},\
"templateParameters": [\
{\
"name": "deploymentId",\
"value": "6788662"\
}\
],\
"recipients": [\
{\
"@odata.type": "microsoft.graph.aadUserNotificationRecipient",\
"userId": "569363e2-4e49-4661-87f2-16f245c5d66a"\
},\
{\
"@odata.type": "microsoft.graph.aadUserNotificationRecipient",\
"userId": "ab88234e-0874-477c-9638-d144296ed04f"\
},\
{\
"@odata.type": "microsoft.graph.aadUserNotificationRecipient",\
"userId": "01c64f53-69aa-42c7-9b7f-9f75195d6bfc"\
}\
]\
}\
'
// 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"
graphteamwork "github.com/microsoftgraph/msgraph-beta-sdk-go/teamwork"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphteamwork.NewSendActivityNotificationToRecipientsPostRequestBody()
topic := graphmodels.NewTeamworkActivityTopic()
source := graphmodels.TEXT_TEAMWORKACTIVITYTOPICSOURCE
topic.SetSource(&source)
value := "Deployment Approvals Channel"
topic.SetValue(&value)
webUrl := "https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000"
topic.SetWebUrl(&webUrl)
requestBody.SetTopic(topic)
activityType := "deploymentApprovalRequired"
requestBody.SetActivityType(&activityType)
previewText := graphmodels.NewItemBody()
content := "New deployment requires your approval"
previewText.SetContent(&content)
requestBody.SetPreviewText(previewText)
keyValuePair := graphmodels.NewKeyValuePair()
name := "deploymentId"
keyValuePair.SetName(&name)
value := "6788662"
keyValuePair.SetValue(&value)
templateParameters := []graphmodels.KeyValuePairable {
keyValuePair,
}
requestBody.SetTemplateParameters(templateParameters)
teamworkNotificationRecipient := graphmodels.NewAadUserNotificationRecipient()
userId := "569363e2-4e49-4661-87f2-16f245c5d66a"
teamworkNotificationRecipient.SetUserId(&userId)
teamworkNotificationRecipient1 := graphmodels.NewAadUserNotificationRecipient()
userId := "ab88234e-0874-477c-9638-d144296ed04f"
teamworkNotificationRecipient1.SetUserId(&userId)
teamworkNotificationRecipient2 := graphmodels.NewAadUserNotificationRecipient()
userId := "01c64f53-69aa-42c7-9b7f-9f75195d6bfc"
teamworkNotificationRecipient2.SetUserId(&userId)
recipients := []graphmodels.TeamworkNotificationRecipientable {
teamworkNotificationRecipient,
teamworkNotificationRecipient1,
teamworkNotificationRecipient2,
}
requestBody.SetRecipients(recipients)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Teamwork().SendActivityNotificationToRecipients().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.teamwork.sendactivitynotificationtorecipients.SendActivityNotificationToRecipientsPostRequestBody sendActivityNotificationToRecipientsPostRequestBody = new com.microsoft.graph.beta.teamwork.sendactivitynotificationtorecipients.SendActivityNotificationToRecipientsPostRequestBody();
TeamworkActivityTopic topic = new TeamworkActivityTopic();
topic.setSource(TeamworkActivityTopicSource.Text);
topic.setValue("Deployment Approvals Channel");
topic.setWebUrl("https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000");
sendActivityNotificationToRecipientsPostRequestBody.setTopic(topic);
sendActivityNotificationToRecipientsPostRequestBody.setActivityType("deploymentApprovalRequired");
ItemBody previewText = new ItemBody();
previewText.setContent("New deployment requires your approval");
sendActivityNotificationToRecipientsPostRequestBody.setPreviewText(previewText);
LinkedList<KeyValuePair> templateParameters = new LinkedList<KeyValuePair>();
KeyValuePair keyValuePair = new KeyValuePair();
keyValuePair.setName("deploymentId");
keyValuePair.setValue("6788662");
templateParameters.add(keyValuePair);
sendActivityNotificationToRecipientsPostRequestBody.setTemplateParameters(templateParameters);
LinkedList<TeamworkNotificationRecipient> recipients = new LinkedList<TeamworkNotificationRecipient>();
AadUserNotificationRecipient teamworkNotificationRecipient = new AadUserNotificationRecipient();
teamworkNotificationRecipient.setOdataType("microsoft.graph.aadUserNotificationRecipient");
teamworkNotificationRecipient.setUserId("569363e2-4e49-4661-87f2-16f245c5d66a");
recipients.add(teamworkNotificationRecipient);
AadUserNotificationRecipient teamworkNotificationRecipient1 = new AadUserNotificationRecipient();
teamworkNotificationRecipient1.setOdataType("microsoft.graph.aadUserNotificationRecipient");
teamworkNotificationRecipient1.setUserId("ab88234e-0874-477c-9638-d144296ed04f");
recipients.add(teamworkNotificationRecipient1);
AadUserNotificationRecipient teamworkNotificationRecipient2 = new AadUserNotificationRecipient();
teamworkNotificationRecipient2.setOdataType("microsoft.graph.aadUserNotificationRecipient");
teamworkNotificationRecipient2.setUserId("01c64f53-69aa-42c7-9b7f-9f75195d6bfc");
recipients.add(teamworkNotificationRecipient2);
sendActivityNotificationToRecipientsPostRequestBody.setRecipients(recipients);
graphClient.teamwork().sendActivityNotificationToRecipients().post(sendActivityNotificationToRecipientsPostRequestBody);
const options = {
authProvider,
};
const client = Client.init(options);
const sendActivityNotificationToRecipients = {
topic: {
source: 'text',
value: 'Deployment Approvals Channel',
webUrl: 'https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000'
},
activityType: 'deploymentApprovalRequired',
previewText: {
content: 'New deployment requires your approval'
},
templateParameters: [
{
name: 'deploymentId',
value: '6788662'
}
],
recipients: [
{
'@odata.type': 'microsoft.graph.aadUserNotificationRecipient',
userId: '569363e2-4e49-4661-87f2-16f245c5d66a'
},
{
'@odata.type': 'microsoft.graph.aadUserNotificationRecipient',
userId: 'ab88234e-0874-477c-9638-d144296ed04f'
},
{
'@odata.type': 'microsoft.graph.aadUserNotificationRecipient',
userId: '01c64f53-69aa-42c7-9b7f-9f75195d6bfc'
}
]
};
await client.api('/teamwork/sendActivityNotificationToRecipients')
.version('beta')
.post(sendActivityNotificationToRecipients);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Teamwork\SendActivityNotificationToRecipients\SendActivityNotificationToRecipientsPostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\TeamworkActivityTopic;
use Microsoft\Graph\Beta\Generated\Models\TeamworkActivityTopicSource;
use Microsoft\Graph\Beta\Generated\Models\ItemBody;
use Microsoft\Graph\Beta\Generated\Models\KeyValuePair;
use Microsoft\Graph\Beta\Generated\Models\TeamworkNotificationRecipient;
use Microsoft\Graph\Beta\Generated\Models\AadUserNotificationRecipient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new SendActivityNotificationToRecipientsPostRequestBody();
$topic = new TeamworkActivityTopic();
$topic->setSource(new TeamworkActivityTopicSource('text'));
$topic->setValue('Deployment Approvals Channel');
$topic->setWebUrl('https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000');
$requestBody->setTopic($topic);
$requestBody->setActivityType('deploymentApprovalRequired');
$previewText = new ItemBody();
$previewText->setContent('New deployment requires your approval');
$requestBody->setPreviewText($previewText);
$templateParametersKeyValuePair1 = new KeyValuePair();
$templateParametersKeyValuePair1->setName('deploymentId');
$templateParametersKeyValuePair1->setValue('6788662');
$templateParametersArray []= $templateParametersKeyValuePair1;
$requestBody->setTemplateParameters($templateParametersArray);
$recipientsTeamworkNotificationRecipient1 = new AadUserNotificationRecipient();
$recipientsTeamworkNotificationRecipient1->setOdataType('microsoft.graph.aadUserNotificationRecipient');
$recipientsTeamworkNotificationRecipient1->setUserId('569363e2-4e49-4661-87f2-16f245c5d66a');
$recipientsArray []= $recipientsTeamworkNotificationRecipient1;
$recipientsTeamworkNotificationRecipient2 = new AadUserNotificationRecipient();
$recipientsTeamworkNotificationRecipient2->setOdataType('microsoft.graph.aadUserNotificationRecipient');
$recipientsTeamworkNotificationRecipient2->setUserId('ab88234e-0874-477c-9638-d144296ed04f');
$recipientsArray []= $recipientsTeamworkNotificationRecipient2;
$recipientsTeamworkNotificationRecipient3 = new AadUserNotificationRecipient();
$recipientsTeamworkNotificationRecipient3->setOdataType('microsoft.graph.aadUserNotificationRecipient');
$recipientsTeamworkNotificationRecipient3->setUserId('01c64f53-69aa-42c7-9b7f-9f75195d6bfc');
$recipientsArray []= $recipientsTeamworkNotificationRecipient3;
$requestBody->setRecipients($recipientsArray);
$graphServiceClient->teamwork()->sendActivityNotificationToRecipients()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Teams
$params = @{
topic = @{
source = "text"
value = "Deployment Approvals Channel"
webUrl = "https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000"
}
activityType = "deploymentApprovalRequired"
previewText = @{
content = "New deployment requires your approval"
}
templateParameters = @(
@{
name = "deploymentId"
value = "6788662"
}
)
recipients = @(
@{
"@odata.type" = "microsoft.graph.aadUserNotificationRecipient"
userId = "569363e2-4e49-4661-87f2-16f245c5d66a"
}
@{
"@odata.type" = "microsoft.graph.aadUserNotificationRecipient"
userId = "ab88234e-0874-477c-9638-d144296ed04f"
}
@{
"@odata.type" = "microsoft.graph.aadUserNotificationRecipient"
userId = "01c64f53-69aa-42c7-9b7f-9f75195d6bfc"
}
)
}
Send-MgBetaTeamworkActivityNotificationToRecipient -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.teamwork.send_activity_notification_to_recipients.send_activity_notification_to_recipients_post_request_body import SendActivityNotificationToRecipientsPostRequestBody
from msgraph_beta.generated.models.teamwork_activity_topic import TeamworkActivityTopic
from msgraph_beta.generated.models.teamwork_activity_topic_source import TeamworkActivityTopicSource
from msgraph_beta.generated.models.item_body import ItemBody
from msgraph_beta.generated.models.key_value_pair import KeyValuePair
from msgraph_beta.generated.models.teamwork_notification_recipient import TeamworkNotificationRecipient
from msgraph_beta.generated.models.aad_user_notification_recipient import AadUserNotificationRecipient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = SendActivityNotificationToRecipientsPostRequestBody(
topic = TeamworkActivityTopic(
source = TeamworkActivityTopicSource.Text,
value = "Deployment Approvals Channel",
web_url = "https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000",
),
activity_type = "deploymentApprovalRequired",
preview_text = ItemBody(
content = "New deployment requires your approval",
),
template_parameters = [
KeyValuePair(
name = "deploymentId",
value = "6788662",
),
],
recipients = [
AadUserNotificationRecipient(
odata_type = "microsoft.graph.aadUserNotificationRecipient",
user_id = "569363e2-4e49-4661-87f2-16f245c5d66a",
),
AadUserNotificationRecipient(
odata_type = "microsoft.graph.aadUserNotificationRecipient",
user_id = "ab88234e-0874-477c-9638-d144296ed04f",
),
AadUserNotificationRecipient(
odata_type = "microsoft.graph.aadUserNotificationRecipient",
user_id = "01c64f53-69aa-42c7-9b7f-9f75195d6bfc",
),
],
)
await graph_client.teamwork.send_activity_notification_to_recipients.post(request_body)