facing issue while using Azure's Face livensss API , not getting desired response in JSON also unable to integrate this api in existing web application created in c# .net

CDSL VENTURES 0 Reputation points
2025-12-05T07:29:22.0766667+00:00

We have referred below link for referral for using rest api created by azure for face liveness detection

https://learn.microsoft.com/en-us/azure/ai-services/computer-vision/tutorials/liveness?tabs=cmd%2Cweb-javascript

but not getting response as shown in document.

Also we want to integrate these services into .net application.

please help how we can use these api for checking face liveness.

we have use postman for checking the api working but we received below response:

1.First API response:

curl --location 'https://faceliveness-clv-dev1.cognitiveservices.azure.com/face/v1.2/detectLivenesswithVerify-sessions' \

--header 'Content-Type: application/json' \

--header 'Ocp-Apim-Subscription-Key: Dm92Jsr5pt5RFRMlezMUg9Abd1bTrlwrNtNdr4JXR8MVLZjyOhq3JQQJ99BKACYeBjFXJ3w3AAAKACOGRFg9' \

--form 'livenessOperationMode="passiveactive"' \

--form 'deviceCorrelationId="723d6d03-ef33-40a8-9682-23a1feb7bccd"' \

--form 'enableSessionImage="true"' \

--form 'VerifyImage=@"/C:/Users/kanchanb/Downloads/WIN_20251121_16_11_49_Pro.jpg"'

Response:

{

"sessionId": "aaa30f61-bc46-4c90-9abf-f7fb345c7a4f",

"authToken": "eyJhbGciOiJFUzI1NiIsImtpZCI6ImtleTEiLCJ0eXAiOiJKV1QifQ.eyJyZWdpb24iOiJlYXN0dXMiLCJzdWJzY3JpcHRpb24taWQiOiJiMWYxMDY5N2UwOWU0NzQ1OTQxMDhkOWI1YzUzM2U2MiIsInByb2R1Y3QtaWQiOiJGYWNlLkYwIiwiYWxsb3dlZC1wYXRocyI6Ilt7XCJwYXRoXCI6XCJmYWNlL3YxLjIvc2Vzc2lvbi9zdGFydFwiLFwibWV0aG9kXCI6XCJQT1NUXCIsXCJxdW90YVwiOjEsXCJjYWxsUmF0ZVJlbmV3YWxQZXJpb2RcIjo2MCxcImNhbGxSYXRlTGltaXRcIjoxfSx7XCJwYXRoXCI6XCJmYWNlL3YxLjIvc2Vzc2lvbi9hdHRlbXB0L2VuZF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aWNlcyJ9.1pfgXQZhxDcj0Lrqn2Jg6DWPd1RWh6CUgthh47ul-RpQGcrEFqjfyhHq7EugULWAHmvEfBMIU7rYIemQxDlVAQ",

"status": "NotStarted",

"modelVersion": "2025-05-20",

"results": {

    "attempts": [],

    "verifyReferences": [

        {

            "referenceType": "image",

            "faceRectangle": {

                "top": 284,

                "left": 887,

                "width": 358,

                "height": 473

            },

            "qualityForRecognition": "high"

        }

    ]

}
```}

2. Second Api Call 

curl --location 'https://faceliveness-clv-dev1.cognitiveservices.azure.com/face/v1.2/detectLivenesswithVerify-sessions/db66ceee-f549-42fe-93cf-f5dcebd6891e' \

--header 'Ocp-Apim-Subscription-Key: Dm92Jsr5pt5RFRMlezMUg9Abd1bTrlwrNtNdr4JXR8MVLZjyOhq3JQQJ99BKACYeBjFXJ3w3AAAKACOGRFg9' \

--header 'Content-Type: application/json' \

--data ''

Response:

{

```typescript
"sessionId": "5c69c355-c4e9-4323-bfa4-ad32149adb3f",

"authToken": "",

"status": "NotStarted",

"results": {

    "attempts": [],

    "verifyReferences": [

        {

            "faceRectangle": {

                "top": 284,

                "left": 887,

                "width": 358,

                "height": 473

            },

            "qualityForRecognition": "high"

        }

    ]

}
```}
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Q&A Assist
    2025-12-05T07:29:51.4733333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To troubleshoot the issues you're facing with Azure's Face Liveness API and its integration into your C# .NET application, consider the following steps:

    1. Check API Key and Endpoint: Ensure that the subscription key and endpoint you are using are correct and that your Azure subscription has access to the Face service. You can verify this by checking your Azure portal.
    2. Session Management: The response from your first API call indicates that the status is "NotStarted." This means that the liveness detection process has not yet begun. You need to wait for the liveness session to complete before making a second call to retrieve the results. The session ID returned in the first response should be used in the second API call to check the status.
    3. Verify Image Quality: Ensure that the image you are using for verification meets the quality requirements. The qualityForRecognition field in your response indicates that the quality is high, which is good. However, you may want to test with different images to see if the results vary.
    4. Integration in C#: For integrating the API into your C# application, you can use the HttpClient class to make REST API calls. Here’s a basic example of how to set up a call:
         using System;
         using System.Net.Http;
         using System.Net.Http.Headers;
         using System.Threading.Tasks;
         
         class Program
         {
             private static readonly HttpClient client = new HttpClient();
         
             static async Task Main()
             {
                 client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "YOUR_SUBSCRIPTION_KEY");
                 var content = new MultipartFormDataContent();
                 content.Add(new StringContent("passiveactive"), "livenessOperationMode");
                 content.Add(new StringContent("723d6d03-ef33-40a8-9682-23a1feb7bccd"), "deviceCorrelationId");
                 content.Add(new StringContent("true"), "enableSessionImage");
                 content.Add(new ByteArrayContent(System.IO.File.ReadAllBytes("path_to_your_image.jpg")), "VerifyImage", "image.jpg");
         
                 var response = await client.PostAsync("https://faceliveness-clv-dev1.cognitiveservices.azure.com/face/v1.2/detectLivenesswithVerify-sessions", content);
                 var responseString = await response.Content.ReadAsStringAsync();
                 Console.WriteLine(responseString);
             }
         }
      
      Replace YOUR_SUBSCRIPTION_KEY and path_to_your_image.jpg with your actual subscription key and the path to your image file.
    5. Postman Testing: If you are testing with Postman, ensure that you are using the correct HTTP method (POST) and that the headers and body are set correctly. The response you receive should match the expected format in the documentation.

    If you continue to experience issues, consider checking the Azure documentation for any updates or changes to the API, and ensure that you are following the latest guidelines for usage.


    References:

    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.