Replace (Not Add) Category On VM Via RestAPI | Nutanix Community
Skip to main content

Greetings everyone,

I have been successful at creating a rest api call to ADD a category to the VM.  The issue is we only want 1 category per VM, so if the VM already has a category assigned we want it to REPLACE the value and not ADD it.  With my current code (ie: use GET command of VM, remove Status, replace categories and categories_mapping then use PUT command) the JSON object looks good before uploading but afterwards I see the new category and the old one.  I tried using a PATCH command but AHV doesn’t like that (and it isn’t in the documentation either).  

 

New Category = NEW_CAT

VM Original State:
    "categories": {

      "OLD_CAT": "OLD_CAT",
    }

 

VM Post My Update State:
    "categories": {

      "OLD_CAT": "OLD_CAT",
      "NEW_CAT": "NEW_CAT"
    }

 

VM Desired State:
    "categories": {

      "NEW_CAT": "NEW_CAT"
    }


Any help would be greatly appreciated.

Be the first to reply!

Reply