How to call Https REST Api from Azure Function written in Java
Bhushan Patil
0
Reputation points
Hello I created an azure function with java, i want to call rest apis with https and i am facing this issue :
SSLHandshakeException@76 "javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target"
this is my function code which i use to call api it is working fine with http urls but throwing above error for https
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(apiBody, mediaType);
Request request = new Request.Builder()
.url(apiUrl)
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
client.newCall(request).execute();