如何通过 QnA Maker API v4.0 更新知识库?

How can I update knowledge base via QnA Maker API v4.0?

我正在尝试使用以下请求调用 QnA Maker API v4.0:

PATCH https://my-test-site.azurewebsites.net/qnamaker/knowledgebases/1d2fb9b0-cc8b-41a4-abbe-3bcb2e497220
Authorization: EndpointKey xxxx
Content-Type: application/json

{
    "add": {
        "qnaList": [
            {
                "id": 0,
                "answer": "Well, hi to you too!",
                "questions": [ "Hi there" ]
            },
        ],
    },
}

我收到回复:

HTTP/1.1 405 Method Not Allowed
{
    "message": "The requested resource does not support http method 'PATCH'."
}

我做错了什么? v4.0 API 不支持这个吗?文档有点奇怪,似乎缺少一些位。

基于此处提供的 API 文档:https://westus.dev.cognitive.microsoft.com/docs/services/5a93fcf85b4ccd136866eb37/operations/5ac266295b4ccd1554da7600

看起来你应该调用以下内容:

https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/knowledgebases/{kbId}

而不是您自己的 Azure QnAMaker 网站。因此,将 my-test-site.azurewebsites.net 替换为 westus.api.cognitive.microsoft.com 并重试。

编辑:我用自己的知识库进行了测试,可以确认您必须使用 Microsoft 认知端点,而不是您的 Azure。 您将收到 202 Accepted 回复,其中提供了 OperationId。

然后您可以使用"Get Operation Details"方法查看操作状态。 https://westus.dev.cognitive.microsoft.com/docs/services/5a93fcf85b4ccd136866eb37/operations/operations_getoperationdetails