2017-04-10 84 views
0

這裏是我的代碼使用Microsoft臉API的對象返回400圖片無效或參數無效

<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"); 
    }); 
}); 

這裏是那裏有文檔的圖像從server`enter時約400性反應我進入或訪問頁面然後它會顯示錯誤的幫助如何解決這個 Here is the image of theres documentation about 400 responce from the server

回答

2

「returnFaceAttributes」:「{}字符串」正在錯誤。 實際上它是{string}的值。應該指定,即年齡,性別......

嘗試用「returnFaceAttributes」:「age」替換「returnFaceAttributes」:「{string}」,它應該可以工作。

檢查文檔:https://www.microsoft.com/cognitive-services/en-us/face-api/documentation/glossary

+0

不過400錯誤的性反應 –

+0

請張貼代碼,我用你確切的代碼與我的變化和它的作品..沒有在結尾忘記逗號? – bukajcihaj

+0

在上面的代碼我改變字符串與年齡 –