microsoft-cognitive - 如何通过 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
并重试。
编辑:我用自己的 KB 进行了测试,可以确认您必须使用 Microsoft 认知端点,而不是您的 Azure 的。您将202 Accepted
收到回复,并提供 OperationId。
然后您可以使用“获取操作详细信息”方法检查操作状态。 https://westus.dev.cognitive.microsoft.com/docs/services/5a93fcf85b4ccd136866eb37/operations/operations_getoperationdetails
推荐阅读
- bash - 如何在脚本中使用外部变量文件
- c# - 使用 Ninject WithConstructorArgument 进行绑定,这是一个接口
- amazon-web-services - 如何使用 Cloudformation 从 S3 存储桶中的代码创建 AWS codecommit 存储库
- python - 使用beautifulsoup时如何找出正确的编码?
- r - 识别 R 中的开始和停止序列以及运行长度
- python - 如何将列表中的两个附近元素相乘?
- python - 尝试训练网络输出:max_pooling2d 从 1 中减去 2 导致的负维度大小
- amazon-web-services - AWS 中的“CharacterSetSettings”
- swift - 根据字段名称过滤对象数组
- python - 如何在 xy 图上绘制循环图