这是我的代码
<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");
});
});
这是当我进入或访问该页面时有关服务器输入400响应的文档的图像,然后显示错误帮助如何解决此问题
最佳答案
“ returnFaceAttributes”:“ {string}”正在产生错误。
实际上,它是{string}值。应该注明年龄,性别...
尝试将“ returnFaceAttributes”:“ {string}”替换为“ returnFaceAttributes”:“ age”,它应该可以工作。
检查文档:https://www.microsoft.com/cognitive-services/en-us/face-api/documentation/glossary