2

我们设置了一个新的 Microsoft Teams 连接器,并成功地将设置设置为 POST 卡到收到的 WebhookUrl。在我们发送的正文中,我们包含了向定义的目标 URL 发出 HttpPost 请求的选项(使用 ngrok.io 隧道进行开发)。您可以在下面看到发送的 messageCard:

{
    "@type": "MessageCard",
    "@context": "https://schema.org/extensions",
    "summary": "Card \"Test card\"",
    "themeColor": "0078D7",
    "title": "Card created: \"Just another test\"",
    "potentialAction": [
        {
            "@type": "ActionCard",
            "name": "Add a comment",
            "inputs": [
                {
                    "@type": "TextInput",
                    "id": "comment",
                    "isMultiline": true,
                    "title": "Enter your comment"
                }
            ],
            "actions": [
                {
                    "@type": "HttpPOST",
                    "name": "Ok",
                    "target": "https://dd846f80.ngrok.io/teamshooks/actions",
                    "body": "{\"Comment\":\"This is a test\"}",
                    "headers": [
                        {
                            "Content-Type": "application/json"
                        },
                        {
                            "aw-teamid": "00000000-0000-0000-0000-000000000001"
                        }
                    ]
                }
            ]
        }
    ]
}

卡片在 Microsoft Teams 的频道中正确显示。当用户单击此按钮时,向指定的 url 发出 HttpPOST,我们从来没有收到我们这边的请求,但可以看到 Microsoft 对内部“executeAction”请求返回以下响应:

请求发送时间:格林威治标准时间 2019 年 12 月 13 日星期五 11:09:48

{
   "status": "Failed",
   "actionId": "c520b20a-3e04-4e21-b4fd-c3a2f760c533",
   "properties":
      { 
          "displayMessage": "<p>Could not complete the requested action. Please try again later.</p>\n",
          "errorCode": "ODataContentTypeException"
      }
}

在连接器开发人员仪表板(和 manifest.json)中设置了以下设置:


"connectors": [
    {
      "connectorId": "6b2ba9c0-7c0a-4524-9e6d-64f061350aa4",
      "scopes": [
        "team"
      ],
      "configurationUrl": "https://dd846f80.ngrok.io/msteams/aworkConnector/config.html"
    }
  ]
 "validDomains": [
    "dd846f80.ngrok.io"
  ]

您想在您的连接器卡上启用操作吗?- 是的

动作网址:https ://dd846f80.ngrok.io/teamshooks/actions


我们目前做错了什么,或者有人知道如何解决返回的 ODataContentTypeException 吗?我们需要在后端接收请求,以便将 Micorsoft Teams 集成到我们的软件中。

4

0 回答 0