How assign a category to a vm within REST API Prism Central | Nutanix Community
Skip to main content

Hello

I would like to use REST API within Prism Central to assign a category to a VM.

I dont know how to do that

Do I need to use this API 

- “Update an existing VM” (put /vms/{uuid})

or this API

- “Create or Update a category value” (put /categories/{name}/{value})


And how can I use it to assign a new category and not remove previous category ?

Regards

Pascal

 

 

 

Ahhh finally I answer to myself :-)

I have to use  “Update an existing VM” (put /vms/{uuid})

and the difficulty for me was to understand what I need to pass for the request payload/body

I need to specify a JSON with the current SPEC of the VM + the metadata with category list

{
  "spec": {
      < every thing of current vm >
  },
  "metadata": {
    "kind": "vm"
    "uuid": <VM UUID>,
    "spec_version": 3,
    "categories_mapping": {
      "ABC1": g
        "abc_1_1"
      ],
      "TEST2": 1
        "test1"
      ]
    },
    "categories": {
      "ABC1": "abc_1_1",
      "TEST2": "test1"
    }
  }
}

 

Not so easy to do but it was ok at the end

Regards


Good to heard you found what you were looking for. In case you want to know more about Nutanix APIs and get familiar on how to use them, you have several blog posts in our Nutanix.dev website.