1

When I was trying to get pessimistic travel time to get on specific time to a destination I get an error: { "error_message" : "Invalid request. Missing the 'departure_time' parameter.", "routes" : [], "status" : "INVALID_REQUEST" } My request is: https://maps.googleapis.com/maps/api/directions/json?units=metric&origin=Split&destination=Solin&mode=driving&language=hr&arrival_time=1518969600&traffic_model=pessimistic&key=*KEY*

When I'm using departure_time instead of arrival_time or when I don't use traffic_model (then it defaults to "best_guess") option then I get results just fine

Luka Svalina
  • 108
  • 12

1 Answers1

2

It's because arrival time can only be specified for travel mode = transit.

As the documentation said:

The departure time may be specified in two cases:

For requests where the travel mode is transit: You can optionally specify one of departure_time or arrival_time. If neither time is specified, the departure_time defaults to now (that is, the departure time defaults to the current time).

For requests where the travel mode is driving: You can specify the departure_time to receive a route and trip duration (response field: duration_in_traffic) that take traffic conditions into account. This option is only available if the request contains a valid API key, or a valid Google Maps APIs Premium Plan client ID and signature. The departure_time must be set to the current time or some time in the future. It cannot be in the past.

Arrival time will be ignored if given for other requests.

You can try yourself to make your request for transit mode and arrival time: https://maps.googleapis.com/maps/api/directions/json?units=metric&origin=Split&destination=Solin&mode=transit&language=hr&arrival_time=1518969600&traffic_model=pessimistic&key=YOURKEY

Alex
  • 599
  • 1
  • 4
  • 16