0
votes

We are developing and that needs the direction APIs to measure the distance between 2 addresses. The only option I have is http as this part of the app doesn't have a map.

I am trying to understand the proper usage of the direction APIs, related Keys and quota.

First we were issuing the http call without a key.

maps.googleapis.com/maps/api/directions/json?origin=43.65077%2C-79.378425&destination=43.63881%2C-79.42745

Sometimes we get back the proper response, but many times I get OVER_QUERY_LIMIT (even though we are hardly issuing any calls, it is impossible that we are triggering any limit)

Then after visiting this link: https://developers.google.com/maps/documentation/directions/usage-limits, we enabled the API key and added the key to the call. So the call now looks like this

http://maps.googleapis.com/maps/api/directions/json?origin=43.65077%2C-79.378425&destination=43.63881%2C-79.42745&key=AI***AQ

Every time, we issue the call, we get back REQUEST_DENIED

3
Why do you say "The only option I have is http as this part of the app doesn't have a map"? The error message I get with your request (including a valid key) is "Requests to this API must be over SSL. Load the API with https: instead of http:". You need to make the requests over https.geocodezip
Can you confirm that Directions API is enabled in your project? Did you apply any restriction on the API key?xomena
The issue was the fact that I was still using http after I added the key. Switching to https solved the problem for meiCAB

3 Answers

0
votes

The error message I get with your request (including a valid key) is "Requests to this API must be over SSL. Load the API with https: instead of http:". You need to make the requests over https.

https://maps.googleapis.com/maps/api/directions/json?origin=43.65077%2C-79.378425&destination=43.63881%2C-79.42745&key=VALID_API_KEY
2
votes

Ensure you have enabled the following APIs

  • Directions API
  • Distance Matrix API
  • Geocoding API
  • Geolocation API
  • Places API

In case its for Android, also enable the following

  • Maps SDK for Android
1
votes

To resolve this issue use the https:// instead of http:// in your base url. I have been testing some items and got the same error message. Once I changed it to https:// I was able to make the call.

Hope this helps anyone else with this issue.