Create droplet from snapshot API not working

May 6, 2018 303 views
API Ubuntu 16.04

I am trying to create a droplet via a curl call from window 10. I have installed curl and it works by itself.

The command I am trying to use is

curl -X POST -H 'Content-Type: application/json' \ -H 'Authorization: Bearer $TOKEN' -d \ '{"name":"blah","region":"nyc3","size":"s-1vcpu-1gb","image": "codenodejs-April-30"}' \ "https://api.digitalocean.com/v2/droplets"

I want to create the droplet from a snapshot. End goal is to create something for quick deployment of images.

I took the command found in the API docs and only changed the token and the image name. I want to add monitoring too but can't even get a droplet without monitoring to work right.

Here is the error message I get

curl: (6) Could not resolve host: application
curl: (6) Could not resolve host: \
curl: (6) Could not resolve host: Bearer
curl: (6) Could not resolve host: TOKEN'
curl: (3) [globbing] unmatched brace in column 2
curl: (3) [globbing] unmatched close brace/bracket in column 20
curl: (6) Could not resolve host: \
{"id": "unauthorized", "message": "Unable to authenticate you." }

1 Answer

It appears that Curl is not parsing your -H options properly and for some reason is seeing them as the target URL.

You seem to have a few \ within the command. Are these escaping line-breaks on Windows?

  • I am not sure about the \ in the commands, I remember basing this originally off the documentation. Here is the output without the \

    C:\Users\jakir>curl -X POST -H 'Content-Type: application/json' -H 'Authorization: Bearer $TOKEN' -d '{"name":"blah","region":"nyc3","size":"s-1vcpu-1gb","image": "codenodejs-April-30"}' "https://api.digitalocean.com/v2/droplets"
    curl: (6) Could not resolve host: application
    curl: (6) Could not resolve host: Bearer
    curl: (6) Could not resolve host: c75cf7391fa0675cdeef55300b2788b646370aaca6df1ad4e0a12636bc24829a'
    curl: (3) [globbing] unmatched close brace/bracket in column 20
    {"id": "unauthorized", "message": "Unable to authenticate you." }

Have another answer? Share your knowledge.