Microsoft Teams HttpPost 操作因 BadRequest 而失败

问题描述

在某些需要员工干预的情况下(这不是关于某种公共团队集成的问题)。 我正在尝试通过向我们的消息添加 HttpPost 操作来向我们的团队工作流程添加可操作的通知:

{
    "@type": "MessageCard","@context": "https://schema.org/extensions","summary": "Manual Verification Required","themeColor": "#2196F3","text": "<message content here>","title": "Manual Verification Required","potentialAction": [
        {
            "@type": "HttpPOST","name": "Approve","target": "https://our.application.host/.teams/webhook","body": "verification.approve"
        }
    ]
}

消息正确到达团队:

Incoming Webhook

点击按钮后,立即出现以下错误消息:

⚠️ 发送失败:
提交您的更改时出现问题。请稍后重试。

挠头后,我打开了 Teams webapp 并检查了控制台:

POST https://teams.microsoft.com/api/mt/emea/beta/users/connectors/19:0d89db468868447a8e526a258788b854@thread.tacv2;messageid=1615721159117/1615721159117/executeAction 400

2021-03-14T11:30:20.322Z [O365ActionPaneController.makeHttpPOSTRequestForConnector()] Http invoke failed: {
  "data": {
    "errorCode": "BadRequest"
  },"status": 400,"config": {
    "method": "POST","transformRequest": [
      null
    ],"transformResponse": [
      null
    ],"url": "https://teams.microsoft.com/api/mt/emea/beta/users/connectors/19:0d89db468868447a8e526a258788b854@thread.tacv2;messageid=1615721159117/1615721159117/executeAction","data": {
      "inputParameters": [],"actionId": "3c5b2184-bffb-4797-9bbd-03fe41e11a83","potentialAction": "{\"@type\":\"HttpPOST\",\"@id\":\"3c5b2184-bffb-4797-9bbd-03fe41e11a83\",\"name\":\"Approve\",\"target\":\"https://our.appplication.host/.teams/webhook\",\"headers\":[],\"body\":\"verification.approve\",\"bodyContentType\":\"\"}","name": "action/connector","integrationId": "8urpi87b0u","meta": "\"{\\\"connectorSenderGuid\\\":\\\"203a1e2c-26cc-47ca-83ae-be98f960b6b2\\\",\\\"providerAccountUniqueId\\\":null,\\\"connectorConfigurationAlternateId\\\":\\\"8a43fac7aa1748688609de3602c9a4c5\\\"}\"","clientInfo": {
        "locale": "en-us","country": "us","platform": "Web","clientVersion": "1415/1.0.0.2021030227"
      }
    },"headers": {
      "X-Skypetoken": "pii","Authorization": "pii","Accept": "application/json,text/plain,*/*","Content-Type": "application/json;charset=utf-8","X-RingOverride": "general","x-ms-scenario-id": "620","x-ms-user-type": null,"x-ms-client-type": "web","x-ms-client-env": "pckgsvc-prod-c1-euno-02","x-ms-client-version": "1415/1.0.0.2021030227","x-ms-session-id": "694afe93-2218-14ab-fd16-d46edaf9fcc5"
    },"counter": "ext_actionable_card_http_post","geoRoutingLookupDuration": 0.014999997802078724,"decrementNetworkRequests": null,"hostName": "teams.microsoft.com","requestCreationDuration": 0.09000004455447197,"requestStartTime": 3355762.155000033,"responseStartTime": 3356549.715000001,"requestDuration": 787.5649999482557
  },"statusText": ""
}

因此,从服务器返回的唯一有价值的信息似乎是响应 {"errorCode":"BadRequest"}。有点薄。

我尝试了 body 属性的不同变体——带引号、不带、带内容类型、空——没有变化。

我需要做什么才能使消息操作生效?

解决方法

我复制了您提供的相同代码,并使用我的工作目标 URL 进行了测试,它完全正常工作。我认为问题出在您的目标 URL 上,能否请您在邮递员中检查您的目标 URL。 enter image description hereenter image description here

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...