title: Sending a request to google direction API to get a path
body: <p>I copied this entire class which sends a route request to google direction API. 
  The function of this class returns in the form of JSON the path between two given points in the url.</p>
  
  <pre><code>import android.util.Log;
  
  import org.apache.http.HttpEntity;
  import org.apache.http.HttpResponse;
  import org.apache.http.client.ClientProtocolException;
  import org.apache.http.client.methods.HttpPost;
  import org.apache.http.impl.client.DefaultHttpClient;
  import org.json.JSONObject;
  
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.io.UnsupportedEncodingException;
  
  public class JSONParser {
  
      static InputStream is = null;
      static JSONObject jObj = null;
      static String json = "";
      // constructor
      public JSONParser() {
      }
      public String getJSONFromUrl(String url) {
  
          // Making HTTP request
          try {
              // defaultHttpClient
              DefaultHttpClient httpClient = new DefaultHttpClient();
              HttpPost httpPost = new HttpPost(url);
  
              HttpResponse httpResponse = httpClient.execute(httpPost);
              HttpEntity httpEntity = httpResponse.getEntity();
              is = httpEntity.getContent();
  
          } catch (UnsupportedEncodingException e) {
              e.printStackTrace();
          } catch (ClientProtocolException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
          try {
              BufferedReader reader = new BufferedReader(new InputStreamReader(
                      is, "iso-8859-1"), 8);
              StringBuilder sb = new StringBuilder();
              String line = null;
              while ((line = reader.readLine()) != null) {
                  sb.append(line + "\n");
              }
  
              json = sb.toString();
              is.close();
          } catch (Exception e) {
              Log.e("Buffer Error", "Error converting result " + e.toString());
          }
          Log.d("JSON_RUTA", json);
          return json;
  
      }
  }
  </code></pre>
  
  <p>For an unknown reason, in the line <code>HttpResponse httpResponse = httpClient.execute(httpPost);</code> the app crashes, I understand that this is the main line where the request is sent to the server, but I have no idea why this is happening, I would be happy if you help me, thank-you very much.</p>