【发布时间】:2023-01-20 08:09:10
【问题描述】:
我在通过 Outlook 电子邮件进行自适应卡片刷新时遇到问题。我在 Outlook 电子邮件中实现了一个操作按钮。我使用 .net4.5 WCF 调用刷新服务并尝试刷新卡片。我的自适应卡版本设置为 1.0,JSON 有效负载是从 MS adaptiveCards Designer here 设计的。
点击后“接受”通过电子邮件的操作按钮。
它每次都显示此错误并且卡没有更改。
世界城市基金会:
[OperationContract]
[WebInvoke(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, Method = "POST")]
JSONObject adaptiveCardsRefresh();
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(已在 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."
}
]
}
我尝试注销返回对象,它作为有效的 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."}]}
【问题讨论】:
-
查找更详细的日志,帮助定位问题。在您的案例中正常返回 json 字符串表明该方法有效,但问题出在其他地方。
标签: c# asp.net wcf outlook adaptive-cards