Question

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

  • 19 November 2021
  • 3 replies
  • 388 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?


3 replies

Userlevel 3
Badge +5

@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. 

Userlevel 1
Badge +3

Hi !

Even though i’m able to get all VM details through GET REST API Call, i’m actually not able to update only one property.

How can you update specifical property you retrieved (ex: category, disk size etc...)?

 

Thanks a lot :)

Userlevel 1
Badge +3

Hi ! finally found a solution to do what I need in Powershell

All explanation was made in my ServerFault post (question + solution) below :

https://serverfault.com/questions/1135179/update-json-payload-using-powershell-and-nutanix-api/1135270#1135270

Reply