API v2 - You specified an invalid image for Droplet creation.

June 23, 2014 6.4k views

As you read the title when i make request with PHP cURL i get the response message of invalid image.

I can see all the image listings "/v2/images/" including the one i request with JSON data which looks like this:
"name": "My-Droplet",
"region": "nyc1",
"size": "4gb",
"image": 4201396
Now the image 4201396 is totally exist and I also able to get image details "/v2/images/4201396".

Why the droplet creation API method didn't recognize the image id? How can i prevent the error? And why the error occurred?

9 Answers

Are you trying to create the droplet in the NYC1 datacenter? Notice that's the only region that it is listed as being available in.

  • You don't mean that i have to physically be located in "NYC1" data-center right? If you mean I need to define it as a region, then I've already done that.

    By the way I've following regions for the image

    "regions": [

    I have chosen <code>nyc1</code> I tried all the regions but none of them solved the issue.

  • No. I read your question as saying that the JSON you shared was what was returned when you queried <code>/v2/images</code> not what you were trying to create. Sorry.

    Can you share exactly how you're trying to call the API? Remember on POSTs you need to set <code>Content-Type: application/json</code> on the request headers. So it would look like:

    curl -X POST "https://api.digitalocean.com/v2/droplets" \
    -d'{"name":"My-Droplet","region":"nyc1","size":"512mb","image":4201396}' \
    -H "Authorization: Bearer $DOAPIv2KEY" \
    -H "Content-Type: application/json"

I'm having the same issue. Did you you resolve this? What was the solution?

I'm also having this same issue. I've tried using both a slug as a string and an image id as a number when posting to the API. I'm also only using regions where the image is available. Any idea what's going on?

Yep, I have the same problem. Sometimes you need to call the API a few times before it is successful.

Did anyone solve the issue? "Sometimes you need to call the API a few times before it is successful."
This sounds like "voodoo" and i don't like it. :)

I have same issue.. Did anybody get any solution?

I have same issue..

I tried with id, name and slug and no ones work

Did anybody get any solution?

I have same issue. Not able to create droplet using image from web api call.

Have another answer? Share your knowledge.