httprequest en android falla y la excepción es null

Tengo una petición HTTP que arroja una excepción null .

Aquí está el código:

 public String updateRounds() { // Create a new HttpClient and Post Header HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("https://technet.rapaport.com/HTTP/Prices/CSV2_Round.aspx"); // Add your data List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); nameValuePairs.add(new BasicNameValuePair("Username", _user)); nameValuePairs.add(new BasicNameValuePair("Password", _password)); try { httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } ResponseHandler<String> responseHandler = new BasicResponseHandler(); String response = ""; // Execute HTTP Post Request try { response = httpclient.execute(httppost, responseHandler); // it gets // exception // here } catch (Exception e) { e.getMessage(); // e is null } return response; } 

¿Alguien tiene alguna idea de por qué sucede esto?

Gracias a todos por intentar ayudar. He cambiado el

 e.getMessage(); 

a

 e.printStackTrace(); 

Y vi que la excepción era sobre el certificado de ssl. Así que manejé eso y ahora funciona. Gracias a todos.

Usted tiene problema en seguir.

 String response = ""; // Execute HTTP Post Request try { response = httpclient.execute(httppost, responseHandler); //it gets exception here 

¿Qué es responseHandler?

httpclient.execute devuelve HttpResponse y está intentando devolverlo en response (que es String).

Entonces cambia

  String response 

a

 HttpResponse response 

Si realmente desea devolver la cadena a continuación, agregue el código siguiente.

  bufferedReader = new BufferedReader( new InputStreamReader(response.getEntity().getContent())); StringBuffer stringBuffer = new StringBuffer(""); String line = ""; String LineSeparator = System.getProperty("line.separator"); while ((line = bufferedReader.readLine()) != null) { stringBuffer.append(line + LineSeparator); } bufferedReader.close(); return stringBuffer.toString(); 
FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.