0

I'm trying to get my latitude and longitude using Google's Geolocation API

This is what the documantation indcates:

Google Geolocation Documantation

This is my POST request to get the data

$.ajax({
  type: "POST",
  url: "https://www.googleapis.com/geolocation/v1/geolocate?key=API_KEY",
  dataType: "application/json",
  contentType: 'application/json; charset=utf-8',
  data: JSON.stringify({considerIp: true}),
  success: function (response) {
    console.log(response);
  },
});

but I get a 404 response status:

XHR POST https://www.googleapis.com/geolocation/v1/geolocate?key=API_KEY [HTTP/3 404 Not Found 101ms]

although I can see on my Google Cloud platform that the requests are correctly made, but returned with an error.

What am I missing?

VectorXY
  • 349
  • 1
  • 3
  • 12
  • 404 is a response It means your doing something wrong. Where is the request body? we need to see what you are sending. There is not enough code here to preproduce the issue. – Linda Lawton - DaImTo Aug 09 '21 at 08:31
  • @DaImTo this is exactly what I am sending :D . I just created my API key and made the post request according to the documantation. I'm stuck here. – VectorXY Aug 09 '21 at 08:36
  • Note the section of the documentation where it states "The request body must be formatted as JSON. The following fields are supported, and all fields are optional, unless otherwise stated:" – Linda Lawton - DaImTo Aug 09 '21 at 09:10
  • Check this you are missing the post data https://stackoverflow.com/a/50572197/1841839 – Linda Lawton - DaImTo Aug 09 '21 at 09:12
  • Yeah still not working. Is this API limited to cellphones? – VectorXY Aug 09 '21 at 09:33
  • I just tested it with postman and it works fine so i dont think so. Edit your question and include your code if you have changed it to add the request body. – Linda Lawton - DaImTo Aug 09 '21 at 10:11

0 Answers0