请求实体太大将自适应卡片发布到 WebHook
Request entity is too large posting adaptive card to 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 : The page was not displayed because the request
entity is too large.
Invoke-RestMethod -uri $URITEST -Method Post -body $bodyJson -Con ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod],
WebException
FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
如果我尝试改变我得到的深度:
Webhook message delivery failed with error: Microsoft Teams endpoint
returned HTTP error 413 with ContextId
MS-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"
}
}
)
}
}
})
}
我正在尝试使用以下代码在 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 : The page was not displayed because the request entity is too large. Invoke-RestMethod -uri $URITEST -Method Post -body $bodyJson -Con ... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
如果我尝试改变我得到的深度:
Webhook message delivery failed with error: Microsoft Teams endpoint returned HTTP error 413 with ContextId MS-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"
}
}
)
}
}
})
}