Share via

Server error 500 using ai-vision detectLivenessWithVerify API

Balázs Baumgartner 0 Reputation points
2025-07-16T16:11:14.2566667+00:00

When we try to use detectLivenessWithVerify with the given payload:


const body = [
        {
          name: "verifyImage" as const,
          body: referenceImage, // Buffer
        },
        {
          name: "livenessOperationMode" as const,
          body: "PassiveActive",
        },
        {
          name: "deviceCorrelationId" as const,
          body: deviceId,
        },
        {
          name: "enableSessionImage" as const,
          body: true,
        },
      ];

We get this error:
HTTP 500

{
    code: "Unspecified"
    message: "Internal server error"
}

Foundry Tools
Foundry Tools

Formerly known as Azure AI Services or Azure Cognitive Services is a unified collection of prebuilt AI capabilities within the Microsoft Foundry platform

0 comments No comments

1 answer

Sort by: Most helpful
  1. Sina Salam 29,846 Reputation points Volunteer Moderator
    2025-07-17T16:25:27.0166667+00:00

    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-Type when using FormData. 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.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.