How to use Geolocation API via curl [closed]

a 夏天 提交于 2021-02-11 12:21:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!