VMware {code} Community
etroska
Contributor
Contributor

Attach disk to a virtual machine with vSphere REST API

Hello,

I need your help.

I created a virtual machine without disks. Now I want to attach an existing vmdk file to the virtual machine via vSphere Rest API.

I call this URL with a POST: https://{{vc}}/rest/vcenter/vm/vm-9550/hardware/disk

And this Payload:

{
    "spec": {
        "backing": {
            "type": "VMDK_FILE",
            "vmdk_file": "[DS-MSD-DATA-NFS001] ISOs/Linux/centos-8.vmdk"
        },
        "type": "SCSI",
        "scsi": {
            "bus": 0,
            "unit": 3
        }
    }
}

 

I got the following error:

{
    "type": "com.vmware.vapi.std.errors.invalid_argument",
    "value": {
        "error_type": "INVALID_ARGUMENT",
        "messages": [
            {
                "args": [],
                "default_message": "Invalid configuration for device '0'.",
                "id": "vmsg.InvalidDeviceSpec.summary"
            },
            {
                "args": [],
                "default_message": "Device: VirtualDisk.",
                "id": "vmsg.com.vmware.vim.vpxd.vpx.vmprov.DeviceStr"
            }
        ]
    }
}

 

I hope you can help me.

Cheers,

etroska

Reply
0 Kudos
0 Replies