Answer the question
In order to leave comments, you need to log in
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
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.
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
$ 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]
{"operation_id":"a606e070d924b7e8e45af94d002004e560f885628f6e3758221f7af59b7c5599","href":"https://uploader9o.disk.yandex.net:443/upload-target/20191211T223927.785.utd.c48dm8nv9r0qh0lgb425q0g3g-k9o.191958","method":"PUT","templated":false}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question