G
G
gene40002020-12-27 12:14:26
Yandex
gene4000, 2020-12-27 12:14:26

Why does Yandex.Locator give a "JSON request is invalid" error?

There is such a service - Yandex Locator, which allows you to find out its coordinates by the MAC Wi-Fi point or by the base cell station. In the description there is an example of a request that I made, but Yandex stubbornly says that the request is incorrect.

json={
    "common":
      {
        "version":"1.0",
        "api_key":"XXХХХХХХХХХХХХХХХХХХХХХХХХХХХХХХХХХXX=="
      },
    "wifi_networks":
      [
        {
          "mac": "2CD02D814C80",
          "signal_strength": -68,
          "age": 500
        }
      ]
    }


Moreover, if someone tries the instructions from the page https://yandex.ru/dev/locator/doc/dg/api/json.html - I want to say right away that it will give an error "did not understand your format" while in the address /geolocation request does not specify the json type, like this: /geolocation?json=1

In general, after adding this parameter, it understands that the request is json, but gives error code 7, which they mean "JSON request is invalid". I tried different options, a list of dots, one, with optional parameters and without mandatory ones, removed square brackets so that there was only one parameter and even put commas after the last parameter. The result is one - error number 7.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
gene4000, 2020-12-27
@gene4000

Problem solved.
Either the request should be:
/geolocation?format=json
or you need to write format=json in the headers, like this:
Content-Type: application/json;format=json

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question