请求实体太大,向WebHook发送自适应卡片



我正在尝试使用以下代码发送带有powershell提及的自适应卡:

$bodyJson = ConvertTo-Json -Depth 8 @{
type = "message"
attachments = @(
{
contentType = "application/vnd.microsoft.card.adaptive"
contentUrl = null
content = {
$"$schema" = "http://adaptivecards.io/schemas/adaptive-card.json",
type = "AdaptiveCard"
version = "1.2"
body = @(
{
type = "TextBlock",
text =  "Test <at>Irvin</at>"
}
)
msteams = {
entities = @(
{
type = "mention"
text = "<at>Irvin</at>"
mentioned = {
id = "myMail"
name = "Irvin Dominin"
}
}
)
}
}
})       
}
Invoke-RestMethod -uri $URITEST -Method Post -body $bodyJson -ContentType "application/json; charset=utf-8"

作为回应,我得到:

Invoke-RestMethod:由于请求,页面未显示实体太大。jquery jquery jquery jquery jquery jquery jquery jquery jquery jquery~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~CategoryInfo: InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest)[调用方法],WebExceptionfulllyqualifiederror: WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

如果我试图改变深度,我得到:

Webhook消息传递失败,错误:Microsoft Teams端点返回HTTP错误413与上下文tidMS-CV = x1G81VkCIEWfRHXA/Qv5Aw.0 . .

看起来你把PowerShell和json语法混在一起了。

你是说

$bodyJson = ConvertTo-Json -Depth 8 @{
type = "message"
attachments = @(
@{
contentType = "application/vnd.microsoft.card.adaptive"
contentUrl = $null
content = @{
schema = "http://adaptivecards.io/schemas/adaptive-card.json"
type = "AdaptiveCard"
version = "1.2"
body = @(
@{
type = "TextBlock"
text =  "Test <at>Irvin</at>"
}
)
msteams = @{
entities = @(
@{
type = "mention"
text = "<at>Irvin</at>"
mentioned = @{
id = "myMail"
name = "Irvin Dominin"
}
}
)
}
}
})       
}

最新更新