Mian Hassan
Mian Hassan

Reputation: 23

Using Microsoft face api its object return 400 that image is invalid or argument is invalid

Here is my code

<script type="text/javascript">
$(function() {
    var params = {
        // Request parameters
        "returnFaceId": "true",
        "returnFaceLandmarks": "false",
        "returnFaceAttributes": "{string}",
    };

    $.ajax({
        url: "https://westus.api.cognitive.microsoft.com/face/v1.0/detect?" + $.param(params),
        beforeSend: function(xhrObj){
            // Request headers
            xhrObj.setRequestHeader("Content-Type","application/json");
            xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","8b99a9ed839a40a08aa8b529ef0f9b8c");
        },
        type: "POST",
        // Request body
        data: '{ "url": "http://heightline.com/wp-content/uploads/Tom-Cruise-smile.jpg" }'
    })
    .done(function(data) {
        alert("success");
    })
    .fail(function() {
        alert("error");
    });
});

Here is the image of theres documentation about 400 responce from the server`enter when i enter or access the page then its shows error help how to resolve this Here is the image of theres documentation about 400 responce from the server

Upvotes: 0

Views: 289

Answers (1)

vanillaSugar
vanillaSugar

Reputation: 551

"returnFaceAttributes": "{string}" is making the error. Actually it is the {string} value. It should be specified, i.e. age, gender ...

Try to replace "returnFaceAttributes": "{string}" with "returnFaceAttributes": "age" and it should work.

Check the documentation: https://www.microsoft.com/cognitive-services/en-us/face-api/documentation/glossary

Upvotes: 2

Related Questions