问题
I have enabled the geolocation API provided by google. I am trying to test it using the command line, but I am getting an error. Although it is mentioned in the documentation that "If you'd like to try the Geolocation API with sample data, save the following JSON to a file:"
and I have saved the request into a file then tried to load it via curl, but it's giving an error in response.
Request File
{
"considerIp": "false",
"wifiAccessPoints": [
{
"macAddress": "00:1f:64:f6:7E:aB"//my system mac address
}
]
}
Curl Request
F:\>curl -d @request.json -H "Content-Type: application/json" -i "https://www.googleapis.com/geolocation/v1/geolocate?key=_Key"
HTTP/1.1 404 Not Found
Vary: X-Origin
Vary: Referer
Content-Type: application/json; charset=UTF-8
Date: Tue, 09 Feb 2021 07:04:40 GMT
Server: scaffolding on HTTPServer2
Cache-Control: private
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Alt-Svc: h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
Accept-Ranges: none
Vary: Origin,Accept-Encoding
Transfer-Encoding: chunked
{
"error": {
"code": 404,
"message": "Requested entity was not found.",
"errors": [
{
"message": "Requested entity was not found.",
"domain": "global",
"reason": "notFound"
}
],
"status": "NOT_FOUND"
}
}
How to use it via postman? Any help would be highly appreciated
来源:https://stackoverflow.com/questions/66099819/how-to-use-geolocation-api-via-curl