【发布时间】:2017-11-11 22:28:40
【问题描述】:
我正在使用 Microsoft Face API 使用 Electron 构建面部识别桌面应用程序。我现在可以检测到人脸并创建一个人物组,但是当我尝试将一个人添加到我的人物组时遇到此错误:
{"error":{"code":"BadArgument","message":"Request body is invalid."}},
这被标记为错误 400。我的控制台上的错误请求。
这是关于如何使用此请求的API 页面:
这是我的代码,显然数据字段有问题,但是当我在 westCentralUS 测试服务器中使用完全相同的数据时,它是成功的。我尝试使用和省略可选的 userData 字段,带有一个字符串和一个图像文件。
function createPerson() {
var params = {
// Request parameters
};
$.ajax({
url: "https://westcentralus.api.cognitive.microsoft.com/face/v1.0/persongroups/students/persons",
beforeSend: function(xhrObj){
// Request headers
xhrObj.setRequestHeader("Content-Type","application/json");
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key",apiKey);
},
type: "POST",
// Request body
data: { name: "John",}
})
.done(function(data) {
alert("success");
})
.fail(function() {
alert("error");
});
}
【问题讨论】:
标签: jquery azure electron face-recognition microsoft-cognitive