【问题标题】:How to use customized cards with Microsoft Teams webhook如何通过 Microsoft Teams webhook 使用自定义卡片
【发布时间】:2019-12-05 00:03:32
【问题描述】:

自适应卡收到“bad request 400”错误

我正在尝试使用 urlopen 方法从运行 Python 3.7 的 AWS Lambda 发送 POST 请求

我有一个正常的卡片请求,但自适应卡片会遇到上述错误。

工作卡示例:

{'@context': 'https://schema.org/extensions', '@type': 'MessageCard', 'themeColor': 'd63333', 'title': '红色警报 - 有问题 警报名称示例', ' text': '示例警报名称已从 OK 更改为 ALARM - Threshold Crossed: 1 个数据点 (10.0) 大于或等于阈值 (1.0)。'}

自定义卡片示例(getting bad request error - 400):

{'@context': 'https://schema.org/extensions', '@type': 'AdaptiveCard', 'padding': 'none', 'body': [{'type': 'Container', 'style': 'emphasis', 'items': [{'type': 'ColumnSet', 'columns': [{'type': 'Column', 'items': [{'type': 'Image', 'horizo​​ntalAlignment': 'Right', 'url': 'https://miro.medium.com/max/1000/1*sszpZOih_xJV_lZsDbog-Q.png', 'height': '50px', 'altText': 'MC Logo'}], 'width': 'auto'}]}] }, {'type': 'Container', 'padding': {'top': 'none', 'left': 'default', 'bottom': 'default', 'right': 'default'}, ' items': [{'type': 'Container', 'items': [{'type': 'ColumnSet', 'spacing': 'Large', 'separator': 1, 'columns': [{'type' : 'Column', 'verticalContentAlignment': 'center', 'items': [{'type': 'Image', 'horizo​​ntalAlignment': 'Center', 'style': 'Person', 'url': '@987654324 @', 'width': '60px', 'altText': '警告标志'}], 'width': '60px'}, {'type': 'Column', 'items': [{'type': 'TextBlock', 'size': 'Medium', 'text': 'Example alarm name 问题描述', 'wrap': 1}, {'type': 'TextBlock', 'spacing' :'无','文本': 'MC ETL Process notifier', 'isSubtle': 1}], 'width': 'stretch'}]}, {'type': 'FactSet', 'facts': [{'title': '事件时间:', 'value': '06/07/2019 03:10:12 AM CT'}, {'title': 'Component:', 'value': 'AWS Glue - 插入资金作业'}, {'title ':'整体夜间完成:','值':'73%'}]},{'type':'TextBlock','spacing':'Small','weight':'Bolder','color': 'Accent', 'size': 'Medium', 'text': 'Click to restart'}, {'type': 'TextBlock', 'spacing': 'Small', 'weight': 'Bolder', 'color ':'口音','大小':'中等','文本':'Click to review logs'}]}]}],'版本':'1.0'}

我的 POST 请求有什么问题?

【问题讨论】:

    标签: post webhooks microsoft-teams


    【解决方案1】:

    目前,Teams 传入的 Webhook 不支持自适应卡片。您只能在连接器消息中发送Message Card。我们正在努力支持自适应卡片,但没有时间表可以分享。

    【讨论】:

    • 非常抱歉:“感谢您的反馈!声望少于 15 人的投票会被记录下来,但不要更改公开显示的帖子得分。”
    • @Trinetra-MSFT 使用 webhook 对自适应卡格式的任何更新,因为我需要一个表格格式,目前无法使用消息卡发送它。虽然我看到了这个:stackoverflow.com/a/60201303/1138192,但我想要这样的东西stackoverflow.com/a/48160573/1138192
    • 现在传入的 Webhook 支持自适应卡。请尝试文档中提到的sample code
    • @Trinetra-MSFT 您是否也可以编辑您的帖子以反映 2020 年 10 月的变化?您的评论很容易被忽略,并可能导致开发人员错过在 Incoming Webhooks 中使用 AdaptiveCards 的能力
    猜你喜欢
    • 2021-08-27
    • 2019-01-18
    • 1970-01-01
    • 1970-01-01
    • 2020-02-17
    • 2021-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多