I'm trying to use the REST API to increase a VM's disk capacity and I tried this REST API but keep getting 400 Bad Request. I tried with VM powered on or off but still getting 400. Does it not allow 'capacity' update?
I followed this REST API:
curl -kv --location --request PATCH 'https://{vcenterurl}/rest/vcenter/vm/vm-22/hardware/disk/4000' \
--header 'vmware-api-session-id: 826f459a3ec1a8cd8b8fc3797a6818fe' \
--header 'mimetype: application/json' \
--header 'Content-Type: application/json' \
--header 'Cookie: vmware-api-session-id=826f459a3ec1a8cd8b8fc3797a6818fe' \
--data-raw '{
"spec": {
"backing": {
"vmdk_file": "[DS10] myVM.vmdk",
"type": "VMDK_FILE",
},
"capacity": 64424509440,
}
}
'
Sorry NOT possible using REST API => use SOAP API
Reply from VMware Support on increasing vDisk size using REST API (dated September 2022) :
I have looked through the documentation and discussed with the engineering team regarding the 3 use cases specified:
Increase size of a VMs vDisk
Connect a VMs NIC to a dvSwitch PortGroup
List and Change properties of a PortGroup
After checking extensively, I understand that we do not have REST API options for these operations. As per my discussion with the engineering team, if the API is not listed here (Link), there is no REST API option and SOAP API would have to be used.
LINK = https://developer.vmware.com/apis/vsphere-automation/latest/vcenter/vm/
Java sample to extend VM hard-disk using VI Java API (SOAP Based) - Extend VM Hard Disk