REST API - Adding VM to Subclient Content

Last post 12 hours, 41 minutes ago by sampath. 3 replies.
Sort Posts: Previous Next
  • REST API - Adding VM to Subclient Content
    Posted: 03-29-2018, 8:17 AM
    Dear,
            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 = "http://test.test.com:81/SearchSvc/CVWebService.svc/Subclient/17"

    $result=Invoke-webrequest -Headers $clientheaders -Uri $NewsubclinetUri -Method POST -Body $newobj2
     
     
    ERROR
    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 =
    @"
    {
    "children":[
    {
    "equalsOrNotEquals":true,
    "path": "",
    "displayName":"2003",
    "name": "",
    "type": 10,
    "allOrAnyChildren":true
    }
    ]
    }
    "@
    $VSASubclientID = "18"
    Invoke-RestMethod -Method PUT -Uri "$WebServer/Subclient/$VSASubclientID/content" -ContentType "application/json" -Headers $headers -Body $Body

    Cheers,
    Luke
    (@cv_skywalker)
  • 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?


    Cheers,
    Luke
    (@cv_skywalker)
  • Re: REST API - Adding VM to Subclient Content
    Posted: 12 hours, 41 minutes ago

    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.

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.
Close
Copyright © 2018 Commvault | All Rights Reserved. | Legal | Privacy Policy