Search code examples
google-mapsgoogle-directions-apimap-directions

Google Directions API error


When I use the following url:

http://maps.googleapis.com/maps/api/directions/json?origin=Cais%20do%20Sodre&destination=Gare%20do%20Oriente&sensor=false&mode=transit

I'm getting the result

{
"routes" : [],
"status" : "INVALID_REQUEST"
}

but it works on google maps. Am I doing something wrong?


Solution

  • When you use transit mode in a directions request, there are additional required parameters:

    Either the arrival_time or the departure_time parameter must be specified any time you request transit directions.

    This returns a response for me:

    http://maps.googleapis.com/maps/api/directions/json?origin=Cais%20do%20Sodre&destination=Gare%20do%20Oriente&sensor=false&mode=transit&arrival_time=12