首页 > 解决方案 > 如何通过 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 不支持这个吗?该文档有点奇怪,似乎缺少一些内容。

标签: microsoft-cognitive

解决方案


基于此处提供的 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.netwestus.api.cognitive.microsoft.com并重试。

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

然后您可以使用“获取操作详细信息”方法检查操作状态。 https://westus.dev.cognitive.microsoft.com/docs/services/5a93fcf85b4ccd136866eb37/operations/operations_getoperationdetails


推荐阅读