Parse error on Google GeoLocate API sample JSON -


has google changed geolocation api , not updated documentation?

i have been following example code verbatim off of following page

https://developers.google.com/maps/documentation/geolocation/intro

i pasted sample request file on system called ex.json. double checked google maps geolocation api set on , executed following curl command

curl -d ex.json -h "content-type: application/json" -i "https://www.googleapis.com/geolocation/v1/geolocate?key=[my key, yes pasted actual key in]" 

i received following response

{  "error": {   "errors": [    {     "domain": "global",     "reason": "parseerror",     "message": "parse error"    }   ],   "code": 400,   "message": "parse error"  } } 

which according documentation means there wrong example json provided. completeness sample json looks

{  "homemobilecountrycode": 310,  "homemobilenetworkcode": 260,  "radiotype": "gsm",  "carrier": "t-mobile",  "celltowers": [   {    "cellid": 39627456,    "locationareacode": 40495,    "mobilecountrycode": 310,    "mobilenetworkcode": 260,    "age": 0,    "signalstrength": -95   }  ],  "wifiaccesspoints": [   {    "macaddress": "01:23:45:67:89:ab",    "signalstrength": 8,    "age": 0,    "signaltonoiseratio": -65,    "channel": 8   },   {    "macaddress": "01:23:45:67:89:ac",    "signalstrength": 4,    "age": 0   }  ] } 

jsonlint verified proper json, , documentation says fields optional. missing, required field added after documentation written?

curl needs "-x post" parameter. works this:

curl 'https://www.googleapis.com/geolocation/v1/geolocate?key=yourkey' -x post -h "content-type: application/json" -d @yourjsonfile.json 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -