I couldn't able to get the 'faceId' in face detect APIs response

NewGene Technologies 0 Reputation points
2024-12-07T12:12:47.87+00:00

Hello

Recently I have created the Face API in console for use in app but it's working as expected kindly suggest me how to do exactly in console.

End point : https://ngtfacerec.cognitiveservices.azure.com/face/v1.0/detect

Subscription Key : 2c87sr7KgQmEswOvwi4iZREWuQVahjxcj8AqBUXOQUQ3RU7fGlTZJQQJ99ALACGhslBXJ3w3AAAKACOGHaTc

I have attached screenshot for your reference.

Notes: Kindly share step for fix the issues

Let me know if you needed anything.

Azure Face
Azure Face
An Azure service that provides artificial intelligence algorithms that detect, recognize, and analyze human faces in images.
172 questions
{count} votes

1 answer

Sort by: Most helpful
  1. navba-MSFT 26,970 Reputation points Microsoft Employee
    2024-12-09T04:33:56.1766667+00:00

    @NewGene Technologies Welcome to Microsoft Q&A Forum, Thank you for posting your query here!

    .

    To perform the FaceDetect Operation from console application, you can leverage the below sample code:

    Note: Please update the {Region} of your face resource and the subscription key in below code:

                string _url = "https://{REGION}.cognitiveservices.azure.com/face/v1.0/detect?returnFaceId=true&returnFaceLandmarks=false&returnFaceAttributes=headpose,mask,qualityforrecognition&recognitionModel=recognition_04&returnRecognitionModel=false&detectionModel=detection_03&faceIdTimeToLive=86400";
                string _key = "XXXXXXXXXXXX"; // Replace with your subscription key
    
                HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(_url);
                wr.ContentType = "application/json";
                wr.Method = "POST";
                wr.Headers.Add("Ocp-Apim-Subscription-Key", _key);
    
                // Define the request body as a JSON string
                string jsonRequestBody = @"{
        ""url"": ""https://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50.jpg""
    }";
    
                // Convert the JSON request body to a byte array
                byte[] postData = System.Text.Encoding.UTF8.GetBytes(jsonRequestBody);
    
                Stream rs = wr.GetRequestStream();
                rs.Write(postData, 0, postData.Length);
                rs.Close();
    
                HttpWebResponse wresp = (HttpWebResponse)wr.GetResponse();
    
                // Read and display the response content
                using (StreamReader streamReader = new StreamReader(wresp.GetResponseStream()))
                {
                    string responseStr = streamReader.ReadToEnd();
                    Console.WriteLine("Response:");
                    Console.WriteLine(responseStr);
                }
    
                wresp.Close();
    
                Console.ReadLine();
    
    

    .

    Hope this helps. If you have any follow-up questions, please let me know. I would be happy to help.

    **

    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    0 comments No comments

Your answer

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