S
S
stasmx2017-02-18 19:20:20
JavaScript
stasmx, 2017-02-18 19:20:20

Problem with WebDav Yandex Disk API??

What am I doing wrong with my request. In postman I get a picture, but in the request through my project I get errors1e9a391c64434e04a1a175bf1bb15ab7.pngd6dba4c73b2540e9a9ed4412ea62fc8b.png2b5118c97be14748bf155196ddc39d29.png

fetch('https://webdav.yandex.ru:443/winter.jpg',{method:'get',
             headers:{
                 'Authorization':'OAuth AQAAAAAaK-00000111Ck0V9f11gmphkERRg5Pw',
                 'Host':'webdav.yandex.ru',
        }})

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
vintage, 2017-02-18
@stasmx

Write to Yandex support to have them fix CORS. The problem here is that they first check the authorization, and then they figure out what method was called. And the browser, before making a request with authorization, pulls the OPTIONS method without authorization, to which the service must return headers allowing cross-domain requests and authorization. And when all the necessary headers are received, it already pulls GET with authorization. And postman wanted to spit on CORS, so everything works for him.

D
Dmitry, 2017-10-20
@DarkByte2015

Good afternoon.
And how does the script determine which record to edit?
Therefore false also returns.
Do not invent and do not engage in nonsense.
First get the model that you will edit, and only then save the changes.
What you are doing now is to create a new entry. Use save() to save the data, although you also need to call save() to update.
ps
This is how a new entry will be made in the database

public function actionAddAuthor() {
  $author = new ArticleAuthor();
  if($author->load(Yii::$app->request->post() && $author->save()){
      return $this->redirect(['article/edit-step3', 'id' => $author->article_id]);
}
}

And here is the update
public function actionEditAuthor($id) {
  $author = $this->findModel($id); // тут select запрос, который возвращает модель для редактирования.
  if($author->load(Yii::$app->request->post() && $author->save()){
      return $this->redirect(['article/edit-step3', 'id' => $author->article_id]);
}
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question