I'm attempting to migrate my bot from QnAMaker v2 API to QnAMaker v4 API. I am able to send updates to the knowledge base, but the publish doesn't seem to take. Here's the code I'm using.
static void Main(string[] args)
{
MainAsync(args).Wait();
}
static async Task MainAsync(string[] args)
{
Console.WriteLine("We're starting.");
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", mySubKey);
var uri = new Uri($"https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/knowledgebases/{myKBId}");
var payload = "{\"add\": {\"qnaList\": [{\"id\": 0,\"answer\": \"A woodchuck could chuck all the wood he could chuck if a woodchuck could chuck wood.\",\"source\": \"Custom Editorial\",\"questions\": [\"How much wood could a woodchuck chuck if a woodchuck could chuck wood?\"],\"metadata\": []}]},\"delete\": {},\"update\": {}}";
var method = new HttpMethod("PATCH");
var request = new HttpRequestMessage(method, uri);
request.Content = new StringContent(payload, Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var responseMessage = await response.Content.ReadAsStringAsync();
Console.Write(responseMessage);
Console.ReadLine();
method = new HttpMethod("POST");
payload = "";
request = new HttpRequestMessage(method, uri);
request.Content = new StringContent(payload, Encoding.UTF8, "application/json");
response = await client.SendAsync(request);
responseMessage = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseMessage);
Console.ReadLine();
}
My test process is
- Ask the bot about woodchucks.
- Run this code.
- Verify the q/a pair about woodchucks is in the knowledge base.
- Ask the bot about woodchucks again.
So far the api responds as expected, but my bot remains oblivious to critical woodchuck knowledge until I click publish on the qnamaker.ai site. What am I missing?