简体   繁体   English

AdaptiveCards 动作刷新卡片无法使用 C# WCF 服务

[英]AdaptiveCards action refresh cards does not work using C# WCF Services

I have a problem with adaptive card refresh via Outlook email. I am implementing an action button in an Outlook email. I using the .net4.5 WCF to call the refresh services and try to refresh the cards.我在通过 Outlook email 刷新自适应卡片时遇到问题。我在 Outlook email 中实现了一个操作按钮。我使用 .net4.5 WCF 调用刷新服务并尝试刷新卡片。 My adaptive cards version is set to 1.0 and JSON payloads are designed from MS adaptiveCards Designer here .我的自适应卡版本设置为 1.0,JSON 有效负载是从此处的 MS adaptiveCards Designer 设计的。

After clicking the "Accept" action button via email.通过 email 单击“接受”操作按钮后。

在此处输入图像描述

It shows this error every time and the cards are not changed.它每次都显示此错误并且卡没有更改。

在此处输入图像描述

WCF: WCF:

[OperationContract]
[WebInvoke(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, Method = "POST")]
JSONObject adaptiveCardsRefresh();

adaptiveCardsRefresh method: adaptiveCardsRefresh 方法:

public JSONObject adaptiveCardsRefresh()
{
  JSONObject obj = new JSONObject();   
  var jsonStr = GetAdaptiveCardContent("workFlowEmailApproved.json");
  obj = JsonConvert.DeserializeObject<JSONObject>(jsonStr);

  WebOperationContext.Current.OutgoingResponse.Headers.Add("CARD-UPDATE-IN-BODY", "true");
  WebOperationContext.Current.OutgoingResponse.ContentType = "application/json";
    
  return obj;
}

workFlowEmailApproved.json (already tested in MS Adaptivecards Designer): workFlowEmailApproved.json (已在 MS Adaptivecards Designer 中测试):

{
    "type": "AdaptiveCard",
    "version": "1.0",
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "originator": "<my-originator-id>",        
    "body": [
        {
            "type": "TextBlock",
            "text": "The action has been recorded."
        }
    ]
}

I try to log out the return object, it seems normal as a valid JSON format:我尝试注销返回 object,作为有效的 JSON 格式似乎很正常:

Return SerializeObject: {"type":"AdaptiveCard","$schema":"http://adaptivecards.io/schemas/adaptive-card.json","originator":"<my-originator-id>","body":[{"type":"TextBlock","text":"The action has been recorded."}]}

I think in your request you need to make sure that your post request has the following headers我认为在您的请求中,您需要确保您的帖子请求具有以下标头

  1. Authorization = ""授权=“”
  2. Content-type = "application/json"内容类型 = “应用程序/json”

When I didn't have the Authorization header I got similar error messages.当我没有授权 header 时,我收到了类似的错误消息。 I think this is because Outlook automatically sends its own Bearer token otherwise我认为这是因为 Outlook 否则会自动发送自己的 Bearer 令牌

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM