title: org.json.JSONException: No value for overview_polyLine
body: <p>I'm creating an app which draws a route from users current location to the destination location entered by the user.</p>
  
  <p>While using the Direction API, I am getting the data from the API but along with an error "org.json.JSONException: No value for overview_polyLine"</p>
  
  <pre><code>
      private void getDirection() {
  
          // currentPosition = new LatLng(mLastLocation.getLatitude(), mLastLocation.getLongitude());
          if (mLastLocation != null) {
              currentPosition = new LatLng (mLastLocation.getLatitude (), mLastLocation.getLongitude ());
          }
  
          String requestApi;
          try {
              requestApi = "https://maps.googleapis.com/maps/api/directions/json?" + "mode=driving&amp;" + "transit_routing_preference=less_driving&amp;" +
                      "origin=" + currentPosition.latitude + "," + currentPosition.longitude + "&amp;" +
                      "destination=" + destination + "&amp;" +
                      "key=" + getResources ().getString (R.string.google_direction_api);
              Log.d ("Ashutosh", requestApi);
              mService.getPath (requestApi)
                      .enqueue (new Callback&lt;String&gt; () {
                          @Override
                          public void onResponse(Call&lt;String&gt; call, Response&lt;String&gt; response) {
                              try {
  
                                  JSONObject jsonObject = new JSONObject (response.body ().toString ());
                                  JSONArray jsonArray = jsonObject.getJSONArray ("routes");
                                  JSONObject route = jsonArray.getJSONObject (0);
                                  JSONObject poly = route.getJSONObject ("overview_polyLine");
                                  String polyline = poly.getString ("points");
                                  polyLineList = decodePoly (polyline);
                                  if (!polyLineList.isEmpty ()) {
                                      LatLngBounds.Builder builder = new LatLngBounds.Builder ();
                                      for (LatLng latLng : polyLineList) {
                                          builder.include (latLng);
                                      }
                                      LatLngBounds bounds = builder.build ();
                                      CameraUpdate mCameraUpdate = CameraUpdateFactory.newLatLngBounds (bounds, 2);
                                      mMap.animateCamera (mCameraUpdate);
  
  
                                  }
  
                                  polylineOptions = new PolylineOptions ();
                                  polylineOptions.color (Color.BLUE);
                                  polylineOptions.width (5);
                                  polylineOptions.startCap (new SquareCap ());
                                  polylineOptions.endCap (new SquareCap ());
                                  polylineOptions.jointType (JointType.ROUND);
                                  polylineOptions.addAll (polyLineList);
                                  greyPolyline = mMap.addPolyline (polylineOptions);
  
                                  blackpolyLineOptions = new PolylineOptions ();
                                  blackpolyLineOptions.color (Color.BLACK);
                                  blackpolyLineOptions.width (5);
                                  blackpolyLineOptions.startCap (new SquareCap ());
                                  blackpolyLineOptions.endCap (new SquareCap ());
                                  blackpolyLineOptions.jointType (JointType.ROUND);
                                  blackPolyline = mMap.addPolyline (blackpolyLineOptions);
  
                                  mMap.addMarker (new MarkerOptions ()
                                          .position (polyLineList.get (polyLineList.size () - 1))
                                          .title ("Pickup Location"));
                                  //Animation
                                  ValueAnimator polylineAnimator = ValueAnimator.ofInt (0, 100);
                                  polylineAnimator.setDuration (2000);
                                  polylineAnimator.setInterpolator (new LinearInterpolator ());
                                  polylineAnimator.addUpdateListener (new ValueAnimator.AnimatorUpdateListener () {
                                      @Override
                                      public void onAnimationUpdate(ValueAnimator animation) {
                                          List&lt;LatLng&gt; points = greyPolyline.getPoints ();
                                          int percentValue = (int) animation.getAnimatedValue ();
                                          int size = points.size ();
                                          int new_Points = (int) (size * (percentValue / 100.0f));
                                          List&lt;LatLng&gt; p = points.subList (0, new_Points);
                                          blackPolyline.setPoints (p);
                                      }
                                  });
                                  polylineAnimator.start ();
                                  carMarker = mMap.addMarker (new MarkerOptions ().position (currentPosition)
                                          .flat (true)
                                          .icon (BitmapDescriptorFactory.fromResource (R.drawable.car)));
  
                                  handler = new Handler ();
                                  index = -1;
                                  next = 1;
                                  handler.postDelayed (drawPathRunnable, 3000);
  
                              } catch (JSONException e) {
                                  e.printStackTrace ();
                              }
                          }
  
                          @Override
                          public void onFailure(Call&lt;String&gt; call, Throwable t) {
                              Toast.makeText (MapsActivity.this, "" + t.getMessage (), Toast.LENGTH_SHORT).show ();
                          }
                      });
          } catch (Exception e) {
              e.printStackTrace ();
          }
      }
  
  </code></pre>
  
  <p>I'm getting the data from the API but unable to show on the google maps because of this error.</p>
  
  <p>Error from the Logcat.</p>
  
  <pre><code>2019-10-15 09:41:23.007 13728-13728/com.example.uber W/System.err: org.json.JSONException: No value for overview_polyLine
  2019-10-15 09:41:23.007 13728-13728/com.example.uber W/System.err:     at org.json.JSONObject.get(JSONObject.java:392)
  2019-10-15 09:41:23.007 13728-13728/com.example.uber W/System.err:     at org.json.JSONObject.getJSONObject(JSONObject.java:612)
  2019-10-15 09:41:23.007 13728-13728/com.example.uber W/System.err:     at com.example.uber.MapsActivity$4.onResponse(MapsActivity.java:299)
  2019-10-15 09:41:23.008 13728-13728/com.example.uber W/System.err:     at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:70)
  2019-10-15 09:41:23.008 13728-13728/com.example.uber W/System.err:     at android.os.Handler.handleCallback(Handler.java:808)
  2019-10-15 09:41:23.008 13728-13728/com.example.uber W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:101)
  2019-10-15 09:41:23.008 13728-13728/com.example.uber W/System.err:     at android.os.Looper.loop(Looper.java:166)
  2019-10-15 09:41:23.008 13728-13728/com.example.uber W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:7425)
  2019-10-15 09:41:23.008 13728-13728/com.example.uber W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
  2019-10-15 09:41:23.008 13728-13728/com.example.uber W/System.err:     at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
  2019-10-15 09:41:23.008 13728-13728/com.example.uber W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
  
  </code></pre>