By shmel
As i was trying to automate some filesystem changes on multiple hosts, i need to send droplets into recovery state, connect via ssh into recovery image and make changes to original droplets FS and than boot back into normal mode.
However, there is no way to do this action via API v2 request, only through the web panel, which is frustrating, because i need to go for recovery panel for every single droplet and manually change boot mode to recovery, and than change it back.
So, to free myself from manual labor, i hoped to “Hack around and find out”. I inspected requests that browser send when you press “Boot from recovery ISO” button, and found this request (i cut out all unnecessary info)
curl 'https://cloud.digitalocean.com/api/v1/droplets/25512****/set_boot_device' \
-H 'authority: cloud.digitalocean.com' \
-H 'accept: application/json' \
-H 'referer: https://cloud.digitalocean.com/droplets/25512****/recovery?i=05ae82' \
-H 'cookie: ***********************************\
--data-raw '{"local_disk":false}' \
--compressed
As you can see, the old API v1 is used here, which btw has no documentation left
I tried to send request to old v1 api endpoint with same parameters as for new one
do_change_bootorder() {
local do_token="$1"
local do_droplet_id="$2"
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $do_token" \
-d '{"local_disk":false}' \
"https://api.digitalocean.com/v1/droplets/$do_droplet_id/set_boot_device"
}
But it does not seem to be working
{"id":"api_error","message":"Looks like something went wrong. If this continues, please open a support ticket so we can help you out. ","request_id":"0fd23148-02f8-495a-******"}
I also tried to send same request to v2 API but got another error
{"id":"not_found","message":"route not found"}
I hope someone here can help me solve this problem.
P.s. I don’t wanna solve this problem via:
I want simple API request and i wonder why it’s still not implemented after all these years ?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello,
The API that you are referring to is the internal DigitalOcean API used by their frontend. The public API does not seem to have this functionality in place.
But this sounds like a great idea, sounds like it’d be super useful!
The best thing to do to get your voice heard regarding this would be to head over to our Product Ideas board and post a new idea, including as much information as possible for what you’d like to see implemented.
Hope that helps! - Bobby.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.