1

I am using Microsoft cognitive service face-api and I have done detecting face and I have got face ids. For detecting face, I used an image form online and add urls in request body of the rest api. Now for verifying faces, i used two images and I have two urls. So I got a problem with sending request body.I don't know which data should send in request body

$(function() {
    var params = {
      {
            "faceId1": "c5c24a82-6845-4031-9d5d-978df9175426",
            "faceId2": "815df99c-598f-4926-930a-a734b3fd651c"
      }

    };

    $.ajax({
        url: "https://westus.api.cognitive.microsoft.com/face/v1.0/verify?" + $.param(params),
        beforeSend: function(xhrObj){
            // Request headers
            xhrObj.setRequestHeader("Content-Type","application/json");
            xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
        },
        type: "POST",
        // Request body
        data:"{}";
    })
    .done(function(data) {
        alert("success");
    })
    .fail(function(){
        alert("error");
    });
});
HK boy
  • 1,398
  • 11
  • 17
  • 25

1 Answers1

0

The Face API for Verify shows how to form the body of the request, depending if you want face to face verification or face to person verification. The face to Person would be images that are compared to other images found in a Person object (one you may have created previously).

The REST details of the Face API are here: https://learn.microsoft.com/en-us/rest/api/cognitiveservices/face/face

The body must have the face IDs while the parameters are optional. So, you could technically remove the $.param(params) and have your data in the request body look like this:

data:
"{
  "faceId1": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "faceId2": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}"
Azurespot
  • 3,066
  • 3
  • 45
  • 73