VMware {code} Community
lcqlys
Contributor
Contributor

Increase VM Disk Size using REST API vcenter vm hardware disk: PATCH doesn't work - get 400 error

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: 

https://developer.vmware.com/apis/vsphere-automation/v7.0U1/vcenter/rest/vcenter/vm/vm/hardware/disk...

 

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,
}
}
'

Reply
0 Kudos
2 Replies
JEHolo3
Contributor
Contributor

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/ 

Reply
0 Kudos
doskiran
Enthusiast
Enthusiast

Java sample to extend VM hard-disk using VI Java API (SOAP Based) - Extend VM Hard Disk 

Tags (1)
Reply
0 Kudos