S
S
Sergey c0re2019-12-11 01:07:50
Yandex
Sergey c0re, 2019-12-11 01:07:50

Yandex.Disk REST API: Unable to upload file to disk. error 400 Bad request. what is wrong, how to download?

The application was registered, the token was received.
In accordance with the description
https://yandex.ru/dev/disk/api/reference/upload-ex... I
send a POST request using wget:

wget -S  \
     --header="Authorization: OAuth <ТОКЕН>" \
     --header="Accept: application/json" \
     --header="Content-Type: application/json" \
     --post-data="url=https%3A%2F%2Fget.wallhere.com%2Fphoto%2Fwomen-outdoors-women-model-portrait-depth-of-field-ass-tanned-painted-nails-black-hair-black-tops-lingerie-red-panties-girl-beauty-leg-computer-wallpaper-photo-shoot-thigh-undergarment-pin-up-girl-875506.jpg&path=disk%3A%2FBackuper%2F" \
     https://cloud-api.yandex.net/v1/disk/resources/upload

and everything seems to be correct?
but in response:
HTTP/1.1 400 BAD REQUEST
  Server: nginx
  Date: Tue, 10 Dec 2019 22:05:52 GMT
  Content-Type: application/json
  Content-Length: 223
  Connection: keep-alive
  Access-Control-Allow-Credentials: true
  Yandex-Cloud-Request-ID: rest-eee3ecdb3b6c6ad973dce83ac7119c52-api07e
  Cache-Control: no-cache
  Access-Control-Allow-Origin: *
  Access-Control-Allow-Headers: Accept-Language, Accept, X-Uid, X-HTTP-Method, X-Requested-With, Content-Type, Authorization
2019-12-11 02:05:52 ОШИБКА 400: BAD REQUEST.

PS: or does wget send POST somehow wrong??
UPDATE:
If you send parameters as part of the URL, it seems like something "rustles", but there is no positive result ...
here is such a request, through the URL,
wget  \
     --header="Authorization: <ТОКЕН>" \
     --header="Accept: application/json" \
     --header="Content-Type: application/json" \
     https://cloud-api.yandex.net/v1/disk/resources/upload?url=https%3A%2F%2Ffunik.ru%2Fwp-content%2Fuploads%2F2019%2F03%2F5c10c7476d9c1aa7f809.jpg\&path=disk%3A%2FBackuper%2Fphoto.jpg

fulfills the type successfully, downloads ...
but where is it not clear !?
$ wget  \
>      --header="Authorization: OAuth <ТОКЕН>" \
>      --header="Accept: application/json" \
>      --header="Content-Type: application/json" \
>      https://cloud-api.yandex.net/v1/disk/resources/upload?url=https%3A%2F%2Ffunik.ru%2Fwp-content%2Fuploads%2F2019%2F03%2F5c10c7476d9c1aa7f809.jpg\&path=disk%3A%2FBackuper%2Fphoto.jpg
--2019-12-11 23:39:27--  https://cloud-api.yandex.net/v1/disk/resources/upload?url=https%3A%2F%2Ffunik.ru%2Fwp-content%2Fuploads%2F2019%2F03%2F5c10c7476d9c1aa7f809.jpg&path=disk%3A%2FBackuper%2Fphoto.jpg
Распознаётся cloud-api.yandex.net (cloud-api.yandex.net)... 213.180.204.127, 2a02:6b8::1:127
Подключение к cloud-api.yandex.net (cloud-api.yandex.net)|213.180.204.127|:443... соединение установлено.
HTTP-запрос отправлен. Ожидание ответа... 200 OK
Длина: 239 [application/json]
Сохранение в каталог: ««upload?url=https%3A%2F%2Ffunik.ru%2Fwp-content%2Fuploads%2F2019%2F03%2F5c10c7476d9c1aa7f809.jpg&path=disk%3A%2FBackuper%2Fphoto.jpg.1»».

upload?url=https%3A%2 100%[======================>]     239  --.-KB/s    in 0s      

2019-12-11 23:39:27 (16,4 MB/s) - «upload?url=https%3A%2F%2Ffunik.ru%2Fwp-content%2Fuploads%2F2019%2F03%2F5c10c7476d9c1aa7f809.jpg&path=disk%3A%2FBackuper%2Fphoto.jpg.1» сохранён [239/239]

in response receives such json
{"operation_id":"a606e070d924b7e8e45af94d002004e560f885628f6e3758221f7af59b7c5599","href":"https://uploader9o.disk.yandex.net:443/upload-target/20191211T223927.785.utd.c48dm8nv9r0qh0lgb425q0g3g-k9o.191958","method":"PUT","templated":false}

but where the file itself is saved is not clear ... there is no file ANYWHERE on Yandex.disk.
something seems wrong, it apparently returns a URL for downloading by the PUT method, although it must download the specified file itself and save it to the specified location .... ??

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tester12, 2019-12-11
@tester12

Where to store backups after the death of Yandex.Disk?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question