Hi,
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;
@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();
request1.setFaceId1(passportImageFaceId);
request1.setFaceId2(liveImageFaceId);
VerifyFaceResponse response = null;
WebClient webClient = WebClient.builder().clientConnector(new ReactorClientHttpConnector(httpClient)).build();
response = webClient.post()
.uri("https://domain/face/v1.0/verify")
.header(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON_VALUE)
.header(OCP_APIM_SUBSCRIPTION_KEY, ocpapimsubscriptionkey)
.body(Mono.just(request1),DetectFaceRequest.class)
.retrieve()
.bodyToMono(DetectFaceResponse.class).block();
Previously this was used which worked:
verifyResponse = restTemplate.exchange(getUtil().getFaceVerifyAPIUri(), HttpMethod.POST, entity, String.class).getBody();