REST API - Adding VM to Subclient Content

Last post 05-01-2018, 3:17 AM by ozonne94. 4 replies.
Sort Posts: Previous Next
  • REST API - Adding VM to Subclient Content
    Posted: 03-29-2018, 8:17 AM
            The intent here is to add a virtual machine to a subclient.
     For this i am using the below code\syntax that i found on commvault API documentation. 
    However, i am not able to add the VM to the subclient content. Need your help on this.
    CODE Syntax
    $newobj2 =
    "association": {
    "entity": {
    "appName": "Virtual Server",
    "instanceName": "DefaultInstanceName",
    "backupsetName": "defaultBackupSet",
    "clientName": "client001",
    "subclientName": "subclient001"
    "subClientProperties": {
    "vmContentOperationType": "ADD",
    "vmContent": {
    "children": {
    "@equalsOrNotEquals": "1",
    "@name": "",
    "@displayName": "VM001"


    $clientheaders =@{"Host"="powershell";"Accept"="application/json";"Authtoken"=$token;"Content-Type"="application/json";}

    $NewsubclinetUri = ""

    $result=Invoke-webrequest -Headers $clientheaders -Uri $NewsubclinetUri -Method POST -Body $newobj2
    Invoke-webrequest : { "errorMessage":"Service error","errorCode":102 }
  • Re: REST API - Adding VM to Subclient Content
    Posted: 04-06-2018, 2:49 PM

    You can overwrite the content with a /content call - I'll have to enquire internally as to how we can specify ADD instead of OVERWRITE however.

    Code snippet:

    $Body =
    "path": "",
    "name": "",
    "type": 10,
    $VSASubclientID = "18"
    Invoke-RestMethod -Method PUT -Uri "$WebServer/Subclient/$VSASubclientID/content" -ContentType "application/json" -Headers $headers -Body $Body

  • Re: REST API - Adding VM to Subclient Content
    Posted: 04-12-2018, 9:23 AM

    There was an update pushed out in Service Pack 11 to resolve an item with vmContentOperationType not being picked up correctly - can you confirm what SP you are currently running?   If you're below SP11, can you upgrade?

  • Re: REST API - Adding VM to Subclient Content
    Posted: 04-24-2018, 10:21 AM

    Dear Luke,

                    Thank you for your reply. I am on SP11. I've tested your code and it is working just as you said. 


    Would be really helpful if we find the ADD parameter instead of an overwrite.


    Your help is greatly appreciated.

  • Re: REST API - Adding VM to Subclient Content
    Posted: 05-01-2018, 3:17 AM
    try this to update an existing subclient, tested yesterday and it works but only with xml content. i am trying to get it work with json content
    method = POST
    {{ServerUrl}}/Subclient/byName(clientName='globalvc',appName='Virtual Server',backupsetName='defaultBackupSet',subclientName='testsubclient')
    <appName>Virtual Server</appName>
    <children equalsOrNotEquals="1" name="" displayName="linuxserver" type="VM"/>
    <children equalsOrNotEquals="1" name="" displayName="globalipam" type="VM"/>
    <children equalsOrNotEquals="1" name="" displayName="test" type="VM"/>

     I am trying to find a way to obtain all subclient attached to a particular VM
The content of the forums, threads and posts reflects the thoughts and opinions of each author, and does not represent the thoughts, opinions, plans or strategies of Commvault Systems, Inc. ("Commvault") and Commvault undertakes no obligation to update, correct or modify any statements made in this forum. Any and all third party links, statements, comments, or feedback posted to, or otherwise provided by this forum, thread or post are not affiliated with, nor endorsed by, Commvault.
Commvault, Commvault and logo, the “CV” logo, Commvault Systems, Solving Forward, SIM, Singular Information Management, Simpana, Commvault Galaxy, Unified Data Management, QiNetix, Quick Recovery, QR, CommNet, GridStor, Vault Tracker, InnerVault, QuickSnap, QSnap, Recovery Director, CommServe, CommCell, SnapProtect, ROMS, and CommValue, are trademarks or registered trademarks of Commvault Systems, Inc. All other third party brands, products, service names, trademarks, or registered service marks are the property of and used to identify the products or services of their respective owners. All specifications are subject to change without notice.
Copyright © 2018 Commvault | All Rights Reserved. | Legal | Privacy Policy