Cannot create and attach a vdisk to VM via REST API | Nutanix Community
Skip to main content

Hi,

I am trying to attach a vdisk to a VM. So far I have found that the only way to create and attach a new vdisk to VM is via this API 

POST /vms/{uuid}/disks/attach

I am trying using this curl expression:

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{
  "uuid": "IDEMPOTENT_UUID",
  "vm_disks": s
    {
      "is_cdrom": false,
      "is_empty": false,
      "is_scsi_pass_through": false,
      "is_thin_provisioned": false,
      "vm_disk_create": {
        "size": 1,
        "storage_container_uuid": "CONTAINER_UUID"
      }
    }
  ]
}' 'https://10.10.10.10:9440/api/nutanix/v2.0/vms/VM_UUID/disks/attach' \
--insecure --basic --user obfuscated_username:obfuscated_password

The task fails and error is: “InvalidArgument: Invalid disk size 0”.

What am I missing here?

Thanks for your time,

Ivars

Turns out unit size here is bytes, so minimum value for parameter “size” must be above 2^20, that is, bigger than 1 Gb. API call works then and disk is created and attached.


Thanks for the followup and sharing with the community @Ivars Strazdins   this makes everyone better!