I have been trying to use the new Geolocation API. I got an API key too.
But somehow, the output is given as ‘Not found’.
Can someone please tell me where the error is?
require 'net/http' require 'uri' require 'json' require 'httparty' lac=50039 mnc=86 cid=15471 mcc=404 rssi=-69 cell_towers = [{:cellId => cid, :locationAreaCode => lac, :mobileCountryCode => mcc, :mobileNetworkCode => mnc, :signalStrength => rssi }] param = {:cellTowers => cell_towers} puts param.to_json #puts "https://www.googleapis.com/maps/api/geolocation/v1/geolocate?key=#{api_key}" response = HTTParty.post("https://www.googleapis.com/maps/api/geolocation/v1/geolocate?key=my_key", :body => param.to_json, :header => {"Content-Type" => "application/json"}) puts response temp= response.body puts temp
The output the above code gives is :
{“cellTowers”:[{“cellId”:15471,”locationAreaCode”:50039,”mobileCountryCode”:404,”mobileNetworkCode”:86,”signalStrength”:-69}]}
Not Found
Not Found
The link to the documentation of Google Maps Geolocation API :
https://developers.google.com/maps/documentation/business/geolocation/
When I create a json object manually and run it on command prompt using ‘curl’ command, the output is coming out right.
So I was struggling with this exact same issue, but using a simple http post in .Net…
Seems the API documentation concerning the URL is wrong.
Instead of: https://www.googleapis.com/maps/api/geolocation/v1/geolocate?key=API_key
It’s actually: https://www.googleapis.com/geolocation/v1/geolocate?key=API_key
Hope this helps!