Microsoft Face API - 400 请求正文无效
Microsoft Face API - 400 Request Body is invalid
我正在使用 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");
});
}
尝试
data: JSON.stringify({name: "John"})
相反。
我正在使用 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");
});
}
尝试
data: JSON.stringify({name: "John"})
相反。