user1552987
user1552987

Reputation: 181

directions API returns INVALID_REQUEST for some URLs (and not for others)

I am getting INVALID_REQUEST for certain requests while its working for others. For example, the following returns INVALID_REQUEST

http://maps.googleapis.com/maps/api/directions/json?origin=EC3N4AB&destination=EC4M8AD&sensor=false&mode=transit

I have also tried several other variations like the one below:

http://maps.googleapis.com/maps/api/directions/json?origin=EC3N4AB,UK&destination=EC4M8AD,UK&sensor=false&mode=transit

This same piece of code is working for some postcodes in the UK but returning INVALID_REQUEST for others. If you search for the postcodes in google maps web interface (EC3N4AB and EC4M8AD), the web interface can easily provide directions.

Wondering what is wrong with my URL? Any help will be appreciated.

Cheers,

Upvotes: 1

Views: 1918

Answers (2)

user1552987
user1552987

Reputation: 181

Google made departure_time or arrival_time mandatory on API requests. This URL works:

http://maps.googleapis.com/maps/api/directions/json?origin=EC3N4AB&destination=EC4M8AD&sensor=false&mode=transit&departure_time=1343376768

Thank everyone for their help.

Upvotes: 4

cadetill
cadetill

Reputation: 1572

Try to use region parametre:

http://maps.googleapis.com/maps/api/directions/json?origin=EC3N4AB&destination=EC4M8AD&sensor=false&mode=transit&region=uk

Another reason may be that does not support transit (try with driving, work good ;-) )

Regards

cadetill

Upvotes: 0

Related Questions