Bot Framework C# Luis 获取 > 异常:响应状态代码不表示成功:400(错误请求)
Bot Framework C# Luis Getting > Exception: Response status code does not indicate success: 400 (Bad Request)
我需要帮助将我的 Luis 应用程序集成到 C# Bot Framework Bot
当我将 Luis App 添加到我的 C# Microsoft Bot Framework 聊天机器人并在模拟器中添加 运行 时,出现异常。
异常:响应状态代码不表示成功:400(错误请求)。
另一位开发人员在 Github 上的调试 post 建议添加域,我必须将其添加到我的 LuisModel(见下文)。这没有解决问题。
[LuisModel("", "",
域:"australiaeast.api.cognitive.microsoft.com",暂存 = true)]
单步执行代码,当它调用 new Dialog.RootLuisDialog() 时,我的本地人似乎是正确的这是一个屏幕抓取
消息控制器代码片段
public async Task<HttpResponseMessage> Post([FromBody] Activity activity)
{
// check if activity is of type message
if (activity.Type == ActivityTypes.Message)
{
await Conversation.SendAsync(activity, () => new Dialogs.RootLuisDialog());
}
else
{
HandleSystemMessage(activity);
}
var response = Request.CreateResponse(HttpStatusCode.OK);
return response;
}
Luis Dialog Class
namespace HalChatBot.Dialogs
{
[LuisModel("<MyLuisAppID>", "<MyLuisKey>",
domain: "australiaeast.api.cognitive.microsoft.com", Staging = true)]
[Serializable]
public class RootLuisDialog : LuisDialog<object>
{
[LuisIntent("")]
[LuisIntent("None")]
public async Task None(IDialogContext context, LuisResult result)
{
await context.PostAsync("I am the Default intent");
context.Wait(MessageReceived);
}
[LuisIntent("Greeting")]
public async Task Greeting(IDialogContext context, LuisResult result)
{
await context.PostAsync("I am the Greeting intent");
context.Wait(MessageReceived);
}
}
}
- 运行 fiddler,已加密 400(错误请求),其中声明 模型未发布。请在到达终点前发布您的模型
- 重新发布 MyLuisApp
- 从 LuisModel 中删除了分期
[LuisModel("<MyLuisAppID>", "<MyLuisKey>", domain: "australiaeast.api.cognitive.microsoft.com")]
现在 Luis 集成正在运行。
我需要帮助将我的 Luis 应用程序集成到 C# Bot Framework Bot
当我将 Luis App 添加到我的 C# Microsoft Bot Framework 聊天机器人并在模拟器中添加 运行 时,出现异常。
异常:响应状态代码不表示成功:400(错误请求)。
另一位开发人员在 Github 上的调试 post 建议添加域,我必须将其添加到我的 LuisModel(见下文)。这没有解决问题。
[LuisModel("", "", 域:"australiaeast.api.cognitive.microsoft.com",暂存 = true)]
单步执行代码,当它调用 new Dialog.RootLuisDialog() 时,我的本地人似乎是正确的这是一个屏幕抓取
消息控制器代码片段
public async Task<HttpResponseMessage> Post([FromBody] Activity activity)
{
// check if activity is of type message
if (activity.Type == ActivityTypes.Message)
{
await Conversation.SendAsync(activity, () => new Dialogs.RootLuisDialog());
}
else
{
HandleSystemMessage(activity);
}
var response = Request.CreateResponse(HttpStatusCode.OK);
return response;
}
Luis Dialog Class
namespace HalChatBot.Dialogs
{
[LuisModel("<MyLuisAppID>", "<MyLuisKey>",
domain: "australiaeast.api.cognitive.microsoft.com", Staging = true)]
[Serializable]
public class RootLuisDialog : LuisDialog<object>
{
[LuisIntent("")]
[LuisIntent("None")]
public async Task None(IDialogContext context, LuisResult result)
{
await context.PostAsync("I am the Default intent");
context.Wait(MessageReceived);
}
[LuisIntent("Greeting")]
public async Task Greeting(IDialogContext context, LuisResult result)
{
await context.PostAsync("I am the Greeting intent");
context.Wait(MessageReceived);
}
}
}
- 运行 fiddler,已加密 400(错误请求),其中声明 模型未发布。请在到达终点前发布您的模型
- 重新发布 MyLuisApp
- 从 LuisModel 中删除了分期
[LuisModel("<MyLuisAppID>", "<MyLuisKey>", domain: "australiaeast.api.cognitive.microsoft.com")]
现在 Luis 集成正在运行。