You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Microsoft Teams Webhook发送Adaptive Card返回404的问题排查

发送Teams自适应卡片返回404但纯文本消息正常的问题

我尝试通过有效的Microsoft Teams Webhook发送数据,编写的Python代码如下:

import requests
import json

url = "https://webhooks.valid_url.com/WebhookHandler/test"

payload = json.dumps({
  "type": "message",
  "attachments": [
    {
      "contentType": "application/vnd.microsoft.card.adaptive",
      "contentUrl": None,
      "content": {
        "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
        "type": "AdaptiveCard",
        "version": "1.2",
        "body": [
          {
            "type": "TextBlock",
            "text": "For Samples and Templates, see [https://adaptivecards.io/samples](https://adaptivecards.io/samples)"
          }
        ]
      }
    }
  ]
})
headers = {
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.status_code)

我按照官方文档编写上述代码,但每次发送都返回404状态码,而Webhook URL是有效的。

当我将payload改为以下纯文本格式时,消息能完美发送:

payload = {
    "text": "Hello, this is a message sent to Teams from Python!",
}

纯文本消息可正常发送,但尝试发送带样式的Adaptive Card时就返回404。在官方文档明确Adaptive Card格式有效的情况下,我遗漏了什么导致该问题?


内容的提问来源于stack exchange,提问作者Antu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 23:37:09