I’m setting up an automated droplet creation process in Laravel for an automated deployment setup package I’m making for myself. But for reasons I can’t figure out, I keep getting the error: “You specified an invalid image for Droplet creation.”, when I try to actually create the droplet. I can’t determine if this is a shortcoming of the API, or a flaw in my own logic.
Currently, the process flow looks like this:
available
is true
.min_disk_size
is greater than or equal to the selected disk size.In other words, by the time a region is chosen, I have what should be, in my mind, a perfectly valid selection of droplet size, image, and region. Some other input occurs, like droplet name and SSH keys, and then I post the information. But I consistently get the error that my chosen image is invalid, every time.
I’ve tried multiple combinations of regions, images, and sizes, and I’ve tried posting the image as both the slug and the ID. So far, no change in behaviour.
I’ve seen this question: https://www.digitalocean.com/community/questions/api-v2-you-specified-an-invalid-image-for-droplet-creation, and it seems like their issue was - annoyingly - that the API just wouldn’t work the first few calls, and would need to be called multiple times. This was 3ish years ago now. I certainly hope the issue hasn’t remained unresolved this whole time.
Any thoughts on what could be going wrong here? Is there additional ‘validation’ logic of which image is valid for which region/droplet combination that the API won’t give me? I really don’t want to hardcode any values, as I should be able to obtain valid selections purely through the API.
For reference, here’s an example of what I’m posting to the API:
[
'name' => 'Testing',
'region' => 'nyc1',
'size' => '512mb',
'image' => 'ubuntu-14-04-x64',
'ssh_keys' => [
0 => 'key_id'
],
'backups' => true,
'tags' => [
0 => 'Tag 1'
]
]
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
I am not seeing anything wrong with the format of your request (your example would fail since we no longer offer a 512MB droplet size).
When retrieving the images from the API are you then using the image ID or the image slug as shown in your example for the request? Can you share an example of a request that failed with the values provided?