i was using AsyncHttpClient
link for making http calls but now our server has migrated to HTTPS and I am getting exception javax.net.ssl.SSLPeerUnverified
Here is my code:
private Map mParams;
public void sendata(View v) throws JSONException {
username = (EditText) findViewById(R.id.txtusername);
password = (EditText) findViewById(R.id.txtpassword);
final ProgressDialog pDialog = new ProgressDialog(this);
pDialog.setMessage("Loading...");
pDialog.show();
JSONObject j = new JSONObject();
j.put("password", password.getText());
j.put("username", username.getText());
j.put("Deviceid", 123456789);
j.put("RoleId", 1);
String url = Url;
AsyncHttpClient client = new AsyncHttpClient();
RequestParams params = new RequestParams();
params.put("json", j.toString());
client.post(url, params, new JsonHttpResponseHandler() {
@SuppressLint("NewApi")
public void onSuccess(JSONObject response) {
pDialog.hide();
JSONObject jsnObjct;
try {
JSONObject json = (JSONObject) new JSONTokener(response
.toString()).nextValue();
JSONObject json2 = json.getJSONObject("Data");
JSONArray test = (JSONArray) json2
.getJSONArray("PatientAllergies");
for (int i = 0; i < test.length(); i++) {
json = test.getJSONObject(i);
System.out.print(json.getString("PatientId"));
System.out.print(json.getString("Id"));
System.out.print(json.getString("AllergyName"));
System.out.print(json.getString("Reaction"));
System.out.print(json.getString("OnSetDate"));
}
} catch (JSONException e) {
e.printStackTrace();
}
}
public void onFailure(int statusCode, Header[] headers, String res,
Throwable t) {
pDialog.hide();
}
});
}
JSONObject jsonObject;
private void parsejson(JSONObject response) {
try {
jsonObject = response;
System.out.print(response.toString());
JSONObject jsnObjct = jsonObject.getJSONObject("Data");
System.out.print(jsonObject.toString());
jsnObjct = jsnObjct.getJSONObject("PhysicianDetail");
System.out.print(jsnObjct.toString());
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}