Formerly known as Azure AI Services or Azure Cognitive Services is a unified collection of prebuilt AI capabilities within the Microsoft Foundry platform
Hello Balázs Baumgartner,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that you are having Server error 500 using ai-vision detectLivenessWithVerify API.
To resolve the HTTP 500 error when using detectLivenessWithVerify, you will need to follow these steps:
A. Ensure you're using multipart/form-data correctly to addresses the original problem. If using JavaScript/TypeScript with fetch or axios, structure it like this:
const formData = new FormData();
formData.append(
"verifyImage",
new Blob([referenceImage], { type: "image/jpeg" }), // Or image/png
"reference.jpg"
);
formData.append("livenessOperationMode", "Passive"); // "Active" also supported
formData.append("deviceCorrelationId", deviceId);
formData.append("enableSessionImage", "true");
const response = await fetch("https://<your-region>.api.cognitive.microsoft.com/vision/v3.2/detectLivenessWithVerify", {
method: "POST",
headers: {
"Ocp-Apim-Subscription-Key": "<your-subscription-key>"
// Do NOT set Content-Type here; browser will set correct multipart boundaries
},
body: formData,
});
const result = await response.json();
console.log(result);
B. According to Microsoft Learn on this tutorial - https://learn.microsoft.com/en-us/azure/ai-services/computer-vision/tutorials/liveness , valid values are:
-
"Passive" -
"Active"
Avoid using "PassiveActive" unless explicitly supported in your API version.
C. Confirm Image Format and Size
- Must be JPEG or PNG
- Recommended size:< 4MB
- Must be a valid image buffer
D. Ensure you're calling the correct endpoint, such as POST https://<your-region>.api.cognitive.microsoft.com/vision/v3.2/detectLivenessWithVerify
And using the correct API version (e.g., v3.2 or latest supported).
E. If using SDKs, enable logging to capture the full request/response. This often reveals hidden issues like:
- Invalid headers
- Malformed multipart boundaries
- Authentication failures
Other debugging tips after the above are the followings:
- Test with a known valid image, under 4MB in JPEG/PNG.
- Avoid manually setting
Content-Typewhen usingFormData. The browser/Fetch API handles it. - Make sure referenceImage is a valid Uint8Array or Buffer. If using Node.js, wrap it properly in
Blob. - Confirm endpoint: https://<region>.api.cognitive.microsoft.com/vision/v3.2/detectLivenessWithVerify
I hope this is helpful! Do not hesitate to let me know if you have any other questions or clarifications.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.