使用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
相关产品推荐
相关产品推荐

