2

I am trying to curl the Google Direction API with JSON output by using instructions provided by https://developers.google.com/maps/documentation/directions/?csw=1#JSON

I have tried specifically (this is what is found on the Google Directions API documentation)

curl https://maps.googleapis.com/maps/api/directions/json?origin=Toledo&destination=Madrid&region=es&key=MY_API_KEY

with the following output:

curl https://maps.googleapis.com/maps/api/directions/json?origin=Toledo&destination=Madrid&region=es&key=AIzaSyDSgiKndYh_Kdv17BK2yTeTNhaITShP5Ts
[1] 4174
[2] 4175
[3] 4176
[2]   Done                    destination=Madrid
Roberts-Macintosh:~ RobertLoggia$ {
   "error_message" : "Invalid request. Missing the 'destination' parameter.",
   "routes" : [],
   "status" : "REQUEST_DENIED"
}

[1]-  Done                    curl https://maps.googleapis.com/maps/api/directions/json?origin=Toledo
[3]+  Done                    region=es

I have enabled Google Directions for the project associated with my API key. I was getting an entirely different message completely when it wasn't enabled, and the the server would just reject my hand shake, so I know it's not a matter of my permission to use it, but maybe of the way the http request is structured.

beckah
  • 1,543
  • 6
  • 28
  • 61
  • 3
    The [posted URL (without the key) works in a browser](https://maps.googleapis.com/maps/api/directions/json?origin=Toledo&destination=Madrid&region=es). – geocodezip May 29 '15 at 14:35

1 Answers1

1

So what happened is your & premier means "run in back ground" in *nix. To prevent it pre process your URL, you either have to escape your &s or use a pair of "" or ''

kaho
  • 4,746
  • 1
  • 16
  • 24