【问题标题】:Slack API dialog.open returning 'not_authed' error in C#Slack API dialog.open 在 C# 中返回“not_authed”错误
【发布时间】: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


    【解决方案1】:

    您可以在 Slack API 文档的测试器页面上检查您正在使用的令牌是否与该方法一起使用:

    https://api.slack.com/methods/dialog.open/test

    顺便说一句,文档建议 this method is deprecated 并且您应该考虑改用模态。

    https://api.slack.com/methods/views.open

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-15
      • 2019-01-04
      • 2019-12-11
      相关资源
      最近更新 更多