I need to call "HTTPS" api and pass JSON params with it to the server.
Right now i am trying like this:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("https://myapi call goes here...");
httppost.setHeader("Content-Type", "application/json");
try
{
JSONObject j = new JSONObject();
j.put("email", "my email value goes here");
StringEntity s = new StringEntity(j.toString());
httppost.setEntity(s);
HttpResponse response = httpclient.execute(httppost);
/* Checking response */
if(response != null)
{
responseBody = EntityUtils.toString(response.getEntity());
}
if(responseBody.equals("ok"))
{
}
}
catch (final Exception e)
{
e.printStackTrace();
}
But its gives me exception: SSL Peer unverified: No Peer Certificate.
Please note that i have to use only HTTPS for making call to api.
Anybody any idea??
Take a look at this answer. It is well explained and is probably what you need to correct your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With