API V2: You specified an invalid image for Droplet creation. Why?
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:
- Ask the user to select a droplet size. These are retrieved from the API, not hardcoded, and filtered to ones where
- Ask the user to select an image. These are also retrieved from the API (distribution images only), and filtered to ones where the image
min_disk_sizeis greater than or equal to the selected disk size.
- Ask the user to select a region. These are also retrieved from the API, and filtered to regions that are in the selected size’s array of regions and in the selected image’s array of regions.
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.×