Microsoft Teams中来自卡的Http POST [英] Http POST from card in Microsoft Teams

查看:227
本文介绍了Microsoft Teams中来自卡的Http POST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试使用Teams,Flow和Assembla创建审批工作流,但遇到了一些麻烦.

We are trying to create an approval workflow using Teams, Flow, and Assembla and are running into a bit of trouble.

我们已经成功设置了一些部件,但是我们无法从Teams中的卡片上发起POST操作.

We have a few of the pieces successfully setup however we are unable to initiate a POST action from a card in Teams.

在团队中,我们可以使用传入的Webhook连接器成功创建卡,并获得此结果.

In teams we can successfully create a card using the incoming webhook connector with this result.

这是通过Flow中的POST操作使用以下JSON正文创建的

This is created with the following JSON body from a POST action in Flow

{
    "@@type": "MessageCard",
    "@@context": "http://schema.org/extensions",
    "summary": "This is the summary property",
    "themeColor": "f46b42",
    "sections": [
        {
            "startGroup": true,
            "title": "**Pending Review**",
            "activityTitle": "Ticket Title",
            "activitySubtitle": "Requested by: ",
            "facts": [
                { "name": "Date submitted:", "value": "06/27/2017, 2:44 PM" },
                { "name": "Details:",
                "value": "This ticket is ready for review." }
            ]
        },
        {
            "potentialAction": [
                {

                    "@@type": "HttpPOST",
                    "name": "Approve",
                    "target": "ANOTHER-POST-URL-IS-HERE"
                },
                {


                    "@@type": "HttpPOST",
                    "name": "Deny",
                    "target": "ANOTHER-POST-URL-IS-HERE"
                }
            ]
        }
    ]
}

我们将另一个Flow网址作为卡上两个按钮的目标.要测试此网址,我们可以通过POSTMAN成功发布并继续批准工作流程.

We have another Flow url as the target for both buttons on the card. To test this url we are able to successfully post via POSTMAN and continue the approval workflow.

单击团队"卡片上的按钮时,根本不会通知帖子URL上的流程.没有触发Flow运行.在团队中,非常通用的提交您的更改时遇到问题.请稍后再试."显示错误.

When clicking the button on the Team card the Flow at the post url is in no way notified at all. No run on Flow is triggered. In teams a very generic "There was a problem submitting your changes. Try again in a minute." error is displayed.

经过研究,我遇到了 connectors.md 文件放在Microsoft Teams github页面上,并注意到了文档的这一可爱部分

After researching I ran across the connectors.md file on the Microsoft Teams github page and noticed this lovely part of the documentation

我觉得奇怪的是,在他们的正下方提到可能不支持POST操作,该文档的长度继续显示了在团队中的卡片中使用POST和ActionCard操作的示例.

It seems odd to me that right below them mentioning that POST actions may not be supported the documentation goes on in length to show examples of using POST and ActionCard actions in a card on teams.

所以我的问题是,有什么方法可以使HttpPOST操作从Teams中的自定义卡运行到Microsoft Flow POST URL?

谢谢!

更新:

在进一步测试中,我们确定HttpPOST操作 可以处理几乎所有我们可以提供的 except 以外的帖子网址 Microsoft Flow请求URL.它们是非常长的网址,所以也许 与此有关吗?

Upon further testing we have determined that HttpPOST actions work with just about any post url we can come up with except Microsoft Flow Request URLs. They are exceptionally long urls so maybe that has something to do with it?

这是一个流程请求网址示例.

Here's an example Flow request url.

https://prod-43.westus.logic.azure.com:443/workflows/f86b928acd3d4ecab849f677974f7816/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=ZBxr5GFKQhMp4JXWGmec_L6aqgcaqvCOKUWOf2li-xQ

在网络浏览器中运行团队时,我们可以看到请求 首先发布到api.teams.skype.com网址并返回通用 "ProviderError".其他非流URL也一样,但返回 成功.

When running teams in a web browser we are able to see the request first posts to a api.teams.skype.com url and returns a generic "ProviderError". Other non-flow urls also do the same but return success.

推荐答案

这对我们来说是个头疼的问题-正如您所推测的那样,这应该是可行的.团队,Flow和Outlook团队今天对此进行了故障排除,并找出了正在发生的情况.

This was a head-scratcher for us - as you surmised, this should have worked. The Teams, Flow, and Outlook teams troubleshooted this today and found out what was going on.

您要发布到的URL https://prod-43.westus.logic.azure.com[...]具有嵌入的承载令牌(URL中sig参数的值).当您通过CURL,Fiddler,Postman等将其发布到该URL时,它会起作用,因为存在该令牌.

The URL you are posting to, https://prod-43.westus.logic.azure.com[...] has an embedded bearer token (the value of the sig parameter in the URL). When you POST to that URL via CURL, Fiddler, Postman, etc. it works because that token is present.

但是,当您在可操作的消息中单击HttpPOST按钮时,Outlook在HTTP标头中添加了自己的JWT令牌,这意味着HTTP POST在邮件头中同时具有 sig=承载令牌URL和HTTP标头中的JWT令牌. Flow会检测到这一点并拒绝HTTP POST无效(虽然我们目前不支持JWT令牌,但我们计划将这种情况视为无效,以保持前向兼容性).

However, when you click on a HttpPOST button in an actionable message, Outlook adds its own JWT token in the HTTP header, meaning that the HTTP POST has both a sig= bearer token in the URL and a JWT token in the HTTP header. Flow detects this and rejects the HTTP POST as invalid (while we don't currently support JWT tokens, we plan to, and treat this case as invalid to maintain forward compatibility).

该用例将在将来使用.同时,一种尝试的解决方法是让可操作的消息按钮POST到您的端点,例如https://yoursite.com/accepthttps://yoursite.com/deny(尽可能多地验证JWT),并让这些终结点POST在不使用JWT的情况下直接流动.

This use case will work in the future. In the meantime, one workaround to try would be to have the actionable message buttons POST to your endpoints, e.g. https://yoursite.com/accept and https://yoursite.com/deny (validating the JWT as much as you like) and have these endpoints POST to Flow directly without the JWT.

请告诉我们是否可行.

顺便说一句,您发现的文本是一个文档错误,此错误自已修复:

BTW, the text you found is a documentation bug that has since been fixed:

很抱歉造成混乱.

这篇关于Microsoft Teams中来自卡的Http POST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆