Issue with calling face verify API using two face ids

Devdutta Basu 0 Reputation points


In new java i am not able to use RestTemplate in older java with RestTemplate it worked as normal.

When I am using web client its giving 400 error
Please refer to below code and please help me debug this i am using the headers and body as normal documentation

package aero.sita.sp.spm.dal.dto;

import javax.xml.bind.annotation.XmlRootElement;

public class VerifyFaceRequest {

private String faceId1;
private String faceId2;

public String getFaceId1() {
	return faceId1;
public void setFaceId1(String faceId1) {
	this.faceId1 = faceId1;
public String getFaceId2() {
	return faceId2;
public void setFaceId2(String faceId2) {
	this.faceId2 = faceId2;


package aero.sita.sp.spm.dal.dto;

public class VerifyFaceResponse {

	private boolean isIdentical  ;
	private float confidence;
	public boolean isIdentical() {
		return isIdentical;
	public void setIdentical(boolean isIdentical) {
		this.isIdentical = isIdentical;
	public float getConfidence() {
		return confidence;
	public void setConfidence(float confidence) {
		this.confidence = confidence;

HttpClient httpClient = HttpClient.create().secure(t -> t.sslContext(sslContext));
				  VerifyFaceRequest request1 = new VerifyFaceRequest();

				VerifyFaceResponse response = null;
				WebClient webClient = WebClient.builder().clientConnector(new ReactorClientHttpConnector(httpClient)).build();
		response =
			      .header(OCP_APIM_SUBSCRIPTION_KEY, ocpapimsubscriptionkey)

Previously this was used which worked:

verifyResponse =, HttpMethod.POST, entity, String.class).getBody();
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,443 questions
{count} votes

2 answers

Sort by: Most helpful
  1. YutongTie-MSFT 46,996 Reputation points

    Hello @
    Devdutta Basu

    Thanks for reaching out to us, I want to let you know that Face API Verify feature is under limited access now, if you have not applied for the access and got approval, you may not be able to use it. Please leverage below link for application.

    Face API: Identify and Verify features

    Document reference, please check here -

    If you have already got the access, I may recommend you refer to the official sample for JAVA -

    // // This sample uses the Apache HTTP client from HTTP Components (
    import org.apache.http.HttpEntity;
    import org.apache.http.HttpResponse;
    import org.apache.http.client.HttpClient;
    import org.apache.http.client.methods.HttpGet;
    import org.apache.http.client.utils.URIBuilder;
    import org.apache.http.impl.client.HttpClients;
    import org.apache.http.util.EntityUtils;
    public class JavaSample 
        public static void main(String[] args) 
            HttpClient httpclient = HttpClients.createDefault();
                URIBuilder builder = new URIBuilder("");
                URI uri =;
                HttpPost request = new HttpPost(uri);
                request.setHeader("Content-Type", "application/json");
                request.setHeader("Ocp-Apim-Subscription-Key", "{subscription key}");
                // Request body
                StringEntity reqEntity = new StringEntity("{body}");
                HttpResponse response = httpclient.execute(request);
                HttpEntity entity = response.getEntity();
                if (entity != null) 
            catch (Exception e)

    Reference document -

    I hope this helps.



    0 comments No comments

  2. Devdutta Basu 0 Reputation points

    Hi, sorry it has started working now it was a problem with the account itself. Thanks for your help