vRA 8 - Update a vRA VM custom property

Inputs:-

vraHost(vra:host)

machineID(string)

propertyName(string)

propertyValue(string)

var url = "/iaas/api/machines";
var customProperties = new Properties();
var newProperty = new Properties();
 newProperty.put(propertyName,propertyValue)
 customProperties.put("customProperties",newProperty)
  //System.log(JSON.stringify(customProperties))
var restClient = vraHost.createRestClient();
var request = restClient.createRequest("PATCH", url + "/" + machineID,JSON.stringify(customProperties));
request.setHeader("Content-Type", "application/json")
var response = restClient.execute(request);
statusCodeAttribute = response.statusCode;
System.log("REST Response Status Code: " + statusCodeAttribute);
responseAsString = response.contentAsString;
//System.log("REST Response Content: " + responseAsString);
var output = JSON.parse(response.contentAsString)
System.log(JSON.stringify(output))
Post a Comment (0)
Previous Post Next Post