Microsoft Face API - 400 Request Body Invalid
I am using Microsoft Face API to build a desktop face recognition application using Electron. I can detect a face right now and create a group of people, but I run into this error when I try to add a person to my group of people:
{"error":{"code":"BadArgument","message":"Request body is invalid."}},
which is marked as Error 400. Bad request on my console.
This is the API page on how to use this request:
Here is my code, obviously there is something wrong with the data field, but when I use the exact data on the westCentralUS test server it is successful. I tried to use and omit the optional userData field with the string and image file.
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");
});
}
+3
source to share