Question

I want to update VM only with Categories, but asking for spec_version

  • 19 November 2021
  • 1 reply
  • 14 views

Below are the request details

URL: https://AddressOfServer:9440/api/nutanix/v3/vms/VM_ID

Method : Put

Request Body:

{
    "spec": {
        "name": "My_VM_Name",
        "resources": {
            "power_state": "ON",
            "hardware_clock_timezone": "Asia/Calcutta"
        }
    },
    "metadata": {
        "kind": "vm",
        "categories": {
            "Environment": "Testing",
            "Department": "Dev"
        },
        "entity_version": "",
        "spec_version": 5,
        "spec_hash": ""
    }
}

 

Response:

{
  "api_version": "3.1", 
  "code": 409, 
  "kind": "vm", 
  "message_list": [
    {
      "message": "The entity you are trying to update might have been modified. Please retrieve the entity again before you update. spec version mismatch: specified version 5, requested 9", 
      "reason": "SPEC_VERSION_MISMATCH"
    }
  ], 
  "state": "ERROR"
}
 

 

How I can find or set entity_version,spec_version,spec_hash?


1 reply

Userlevel 2
Badge +4

@MaheshNikam To get the spec_version and entity_version, you will need to first use the GET REST API call for VM (https://AddressOfServer:9440/api/nutanix/v3/vms/{VM-UUID} ), and once you get those details, you can then use it in the above-mentioned PUT API call for updating VMs via REST API. 

Reply