【发布时间】:2020-11-16 16:32:56
【问题描述】:
我有一个使用 Azure Bot Framework 用 C# 编写的机器人。该机器人适用于松弛通道。我正在尝试使用其中一种松弛 API 方法 dialog.open 在获得按钮单击之类的触发器后在聊天中打开一个对话框。我使用下面给出的代码只是为了调用 API,但唯一的问题是我得到了 {"ok":false,"error":"not_authed"} 作为响应。
using (var client = new HttpClient())
{
using (var request = new HttpRequestMessage())
{
request.Method = HttpMethod.Post;
request.RequestUri = new Uri(_configuration["SlackOpenDialog"]);
request.Headers.Add("Authorization", ApiToken);
request.Content = new StringContent(jsonString, Encoding.UTF8, "application/json");
_logger.LogInformation(request.ToString());
var response = await client.SendAsync(request);
if (response.IsSuccessStatusCode)
{
string result = await response.Content.ReadAsStringAsync();
_logger.LogInformation("In" + _functionName + "Dialog > SlackOpenDialogPostAsync > Slack > response ----> " + result);
//return result;
}
else
{
_logger.LogInformation("In" + _functionName + "Dialog > SlackOpenDialogPostAsync > Slack > response ----> " + response.ReasonPhrase);
//return null;
}
}
}
谁能告诉我可能是什么问题,因为我从几个小时以来就一直坚持这个问题。我真的需要一些快速的帮助!
【问题讨论】:
标签: c# http-headers slack-api azure-bot-service