G
G
glebvvs2019-03-03 12:57:26
API
glebvvs, 2019-03-03 12:57:26

Why can't I connect to YandexWebmaster API?

Hello. This is the first time I've come across public APIs and I would like to understand what my mistake is.
I received the debug token, after which I accessed the following URL: https://api.webmaster.yandex.net/v4/user/
Now my request for getting the user ID looks like this.

fetch('https://api.webmaster.yandex.net/v4/user/', {
  method: 'GET',
  headers: {
    "Authorization": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  }
})
.then(response => {
  alert('test');

});

The browser throws the following error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.webmaster.yandex.net/v4/user/. (Reason: CORS header 'Access-Control-Allow-Origin' missing).
TypeError: NetworkError when attempting to fetch resource.

As an option, I tried this query (it did not give results):
fetch('https://api.webmaster.yandex.net/v4/user/', {
  method: 'GET',
  headers: {
                "Access-Control-Allow-Origin": "*",
    "Authorization": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  }
})
.then(response => {
  alert('test');

});

I would like to know how to solve this problem and is something not configured on the Yandex side or my request is just a curve

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2019-03-07
@dimonchik2013

Why can't I connect to the Yandex API?
Why can't I get a response to a request to a remote source?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question