Report this

What is the reason for this report?

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:

  • “copy request as curl with all cookies and ‘foreach’ for all droplets”
  • “automate login and obtaining cookies via beautifulsoup4 python”
  • “automate via selenium”
  • “automate via mouse programming to click on buttons”

I want simple API request and i wonder why it’s still not implemented after all these years ?

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.