You must use an API key to authenticate each request to Google Maps Platform APIs error when directly entering into address bar

in my case i had # in address link input=City Clinical # 89so i had to remove it


You need an API key. Otherwise it won't work.

To get an API Key you have to go to this webpage https://cloud.google.com/maps-platform/#get-started and pick the products you need. Also select or create a project and finally you have to set up a billing account. Unfortunately it isn't for free as far as I know.


Post Values like below:

  String str_origin = "origin=" + origin.latitude + "," + origin.longitude;
    // Destination of route
    String str_dest = "destination=" + dest.latitude + "," + dest.longitude;

    // Sensor enabled
    String sensor = "sensor=true";
    String mode = "mode=driving";
    String key = "key="+getResources().getString(R.string.google_maps_key);
    // Building the parameters to the web service
    String parameters = str_origin + "&" + str_dest + "&" + sensor + "&" + mode + "&" + key;

    // Output format
    String output = "json";

    // Building the url to the web service
    String url = "https://maps.googleapis.com/maps/api/directions/" + output + "?" + parameters;

Tags:

Api