I have been trying to access the geolocation api to locate cell towers I'm no expert at http posts. All I receive is the http code 404. I have concatenated the geolocation web-address, my api-key and the json request. (without newlines/spaces)
https://www.googleapis.com/geolocation/v1/geolocate?
key=myAPIkey
{"homeMobileNetworkCode":2,"homeMobileCountryCode":505,"cellTowers":[{"mobileCountryCode":505,"mobileNetworkCode":2,"locationAreaCode":38501,"cellId":209715676}],"radioType":"WCDMA","considerIp":"false"}
http code 404: notFound geolocation 404 The request was valid, but no results were returned.
I have tried various valid cells, and I cannot believe google doesn't know about any of them!
So I'm none the wiser, it seems the request is valid, but have I made a basic mistake...
My http post method is:
public void getGeo(Cell cell) // cell: mcc, mnc, lac, cid, type, lat, lon, address
{
try
{
String json = formJSON(cell);
String query = GEO + KEY + json;
URL url = new URL(query);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
int code = connection.getResponseCode();
if (code == HttpURLConnection.HTTP_OK)
{
StringBuilder response = new StringBuilder();
BufferedReader reader;
reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = reader.readLine()) != null)
{
response.append(line);
}
reader.close();
String result = response.toString();
parseJSON(result);
this.address = geocodeLocation();
if (!this.error)
{
cell.setLat(this.latitude);
cell.setLon(this.longitude);
cell.setAcc(this.accuracy);
cell.setAddress(this.address);
}
}
}
catch (Exception e)
{
this.error = true;
this.errMsg = e.toString();
}
}
It seems, I had made a GET request and not a POST request. I seem to have worked it out...