Feb 06 2020 05:26 AM
I created an adaptive card and want to send it via PowerShell to a Teams Channel via a webhook. Everything works so far, but the card is shown as a blank line?!
Feb 09 2020 03:09 AM
Feb 09 2020 11:58 PM - edited Feb 10 2020 12:00 AM
$body = @"
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"summary": "Adaptive Card Test",
"body": [
{
"type": "TextBlock",
"text": "Using Microsoft Teams",
"size": "Large",
"weight": "Bolder"
},
{
"type": "Image",
"altText": "",
"url": "https://media.giphy.com/media/WOIGpnJ3ye445BUQl4/giphy.gif"
},
{
"type": "TextBlock",
"text": "Please make sure to read the User Guide first.",
"horizontalAlignment": "Left",
"height": "stretch",
"wrap": true
}
],
"selectAction": {
"type": "Action.OpenUrl",
"title": "Request Office 365 Group",
"url": "https://teams.microsoft.com/xyz"
},
"actions": [
{
"type": "Action.OpenUrl",
"title": "Request Office 365 Group",
"url": "https://teams.microsoft.com/xyz"
}
]
}
"@
$uri = 'https://outlook.office.com/webhook/xyz'
Invoke-RestMethod -uri $uri -Method Post -body $body -ContentType 'application/json'
Feb 10 2020 12:59 AM
Solution@Thomas_Steibl Ah, ok, so I forgot something really important! You can't use Adaptive Cards, you have to use the older MessageCard format. See https://docs.microsoft.com/en-us/outlook/actionable-messages/send-via-connectors for the detail, but this should work:
$body = ' { "@context": "https://schema.org/extensions", "@type": "MessageCard", "themeColor": "0072C6", "title": "Using Microsoft Teams", "text": "Please make sure to read the User Guide first.", "potentialAction": [ { "@type": "OpenUri", "name": "Request Office 365 Group", "targets": [ { "os": "default", "uri": "https://teams.microsoft.com/l/entity/81fef3a6-72aa-4648-a763-de824aeafb7d/_djb2_msteams_prefix_316372079?context=%7B%22subEntityId%22%3Anull%2C%22channelId%22%3A%2219%3A96f7bce5c6e2472a8f6e896ef0e4f875%40thread.skype%22%7D&groupId=d622b046-74e2-46a4-a1c6-63411f915464&tenantId=5176709f-3f1f-4e44-a034-277655f7629c" } ] } ] }'
Should give you:
Feb 10 2020 01:17 AM
Feb 10 2020 12:59 AM
Solution@Thomas_Steibl Ah, ok, so I forgot something really important! You can't use Adaptive Cards, you have to use the older MessageCard format. See https://docs.microsoft.com/en-us/outlook/actionable-messages/send-via-connectors for the detail, but this should work:
$body = ' { "@context": "https://schema.org/extensions", "@type": "MessageCard", "themeColor": "0072C6", "title": "Using Microsoft Teams", "text": "Please make sure to read the User Guide first.", "potentialAction": [ { "@type": "OpenUri", "name": "Request Office 365 Group", "targets": [ { "os": "default", "uri": "https://teams.microsoft.com/l/entity/81fef3a6-72aa-4648-a763-de824aeafb7d/_djb2_msteams_prefix_316372079?context=%7B%22subEntityId%22%3Anull%2C%22channelId%22%3A%2219%3A96f7bce5c6e2472a8f6e896ef0e4f875%40thread.skype%22%7D&groupId=d622b046-74e2-46a4-a1c6-63411f915464&tenantId=5176709f-3f1f-4e44-a034-277655f7629c" } ] } ] }'
Should give you: