使用Action.OpenUrl从Adaptive Card打开任务模块

时间:2019-05-10 10:00:46

标签: microsoft-graph microsoft-teams adaptive-cards

我们正在使用以下 Graph API https://docs.microsoft.com/en-us/graph/api/channel-post-chatmessage?view=graph-rest-beta&tabs=cs

在通道中发布自适应卡

我们的有效载荷是

<samlp:AuthnRequest 
    xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" 
    ID="_2e674db5054e407c30af" 
    Version="2.0" 
    IssueInstant="2019-05-10T09:39:52Z" 
    ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" 
    AssertionConsumerServiceURL="https://my-sp.com/callback">
    <saml:Issuer 
        xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">sp_name
    </saml:Issuer>
    <samlp:NameIDPolicy 
        xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" 
        Format="urn:oasis:names:tc:SAML:2.0:nameid-format:unspecified" 
        AllowCreate="true">
    </samlp:NameIDPolicy>
    <samlp:RequestedAuthnContext 
        xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" 
        Comparison="exact">
        <saml:AuthnContextClassRef 
            xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport
        </saml:AuthnContextClassRef>
    </samlp:RequestedAuthnContext>
</samlp:AuthnRequest>

我们的自适应卡就像

{
  "body":{
    "contentType":"html",
    "content":"<attachment id="attachmentId"></attachment>"  // for attachmentId see attachments section below
  },
  "attachments":[
    {
      "id":"attachmentId",
      "content":cardData // this is JSON.stringify of actual Adaptive card data 
    }
  ]
}

如果我在聊天中发布任务模块网址,然后单击它可以正常工作, 但这不适用于自适应卡 { "type":"AdaptiveCard", "$schema":"http://adaptivecards.io/schemas/adaptive-card.json", "body":"some body", "actions":[ { "type":"Action.OpenUrl", "title":"Suggest Item", "url":"https://teams.microsoft.com/l/task/2a05d07c-d194-400e-8122-cad64cfe1cef?url=https%3A%2F%2Flocalhost%3A44349%2Fteams%2F%23%2Fsuggest%2Fee31b3aa-f60f-4594-a964-a01fcc461ceb%3Ffrom%3Dcard&height=540&width=800&title=*Suggest%20item" } ] } 以前它可以工作

2 个答案:

答案 0 :(得分:2)

任务模块深层链接在Adaptive card OpenUrl中可以正常工作。您可以尝试遵循JSON有效负载吗?

{
             "body": {
                "contentType": "html",
                "content": "<attachment id=\"fa74618d23064677a1af25d0ae973532\"></attachment>"
            },
            "attachments": [
                {
                    "id": "fa74618d23064677a1af25d0ae973532",
                    "contentType": "application/vnd.microsoft.card.adaptive",
                    "content": "{\r\n    \"type\": \"AdaptiveCard\",\r\n    \"actions\": [\r\n        {\r\n            \"type\": \"Action.OpenUrl\",\r\n            \"title\": \"View\",\r\n            \"url\": \"https:\/\/teams.microsoft.com\/l\/task\/f195eed2-4336-4c33-a11b-a417dcaa8680?url=https:\/\/taskmoduletest.azurewebsites.net\/customform&height=430&width=510&title=Custom%20Form&fallbackUrl=https:\/\/taskmoduletest.azurewebsites.net\/customform\"\r\n        }\r\n    ],\r\n    \"$schema\": \"http:\/\/adaptivecards.io\/schemas\/adaptive-card.json\",\r\n    \"version\": \"1.0\"\r\n}"
                }
            ]
}

如果您遇到任何问题,请告诉我们。

答案 1 :(得分:0)

我的标题网址中有一个*,在删除后它仍然可以正常工作