不太清楚您使用的MsQnAMaker.Client內部是怎麼實作的,
但可能原因是發的request body格式不正確
您可以去你azure websites的LOG查看詳細的錯誤訊息
把您要送的request body整理好再POST出去
{
"name" : "QnA Maker FAQ Bot",
"qnaPairs": [
{
"answer": "You can change the default message if you use the QnAMakerDialog. See this for details: https://docs.botframework.com/en-us/azure-bot-service/templates/qnamaker/#navtitle",
"question": "How can I change the default message from QnA Maker?"
},
{
"answer": "You can use our REST apis to manage your KB. See here for details: https://westus.dev.cognitive.microsoft.com/docs/services/58994a073d9e04097c7ba6fe/operations/58994a073d9e041ad42d9baa",
"question": "How do I programmatically update my KB?"
}
],
"urls": [
"https://docs.microsoft.com/en-in/azure/cognitive-services/qnamaker/faqs"
]
}
可能關聯的錯誤400 Error
{
"error": {
"code": "BadArgument",
"message": "Request body is invalid."
}
}
建議可以先用官方的Sample Code測試看看喔
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;
namespace CSHttpClientSample
{
static class Program
{
static void Main()
{
MakeRequest();
Console.WriteLine("Hit ENTER to exit...");
Console.ReadLine();
}
static async void MakeRequest()
{
var client = new HttpClient();
var queryString = HttpUtility.ParseQueryString(string.Empty);
// Request headers
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");
var uri = "https://westus.api.cognitive.microsoft.com/qnamaker/v2.0/knowledgebases/create?" + queryString;
HttpResponseMessage response;
// Request body
byte[] byteData = Encoding.UTF8.GetBytes("{body}");
using (var content = new ByteArrayContent(byteData))
{
content.Headers.ContentType = new MediaTypeHeaderValue("< your content type, i.e. application/json >");
response = await client.PostAsync(uri, content);
}
}
}
}
參考資料:https://westus.dev.cognitive.microsoft.com/docs/services/58994a073d9e04097c7ba6fe/operations/58994a073d9e041ad42d9baa