1 Reply Latest reply on Sep 11, 2019 2:17 AM by shill81

    Execute SOAP request to Add Virtual Machine to DRS Group

    antonnoble_2014 Lurker

      Hi, I've been working with SOAP messages and the vSphere vimService lately. I've ran into a snag. I want to add a virtual machine to an existing DRS group by send a soap call to the API. Here's what I'm trying:


      <soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">




          <ReconfigureComputeResource_Task xmlns="urn:internalvim25">

            <_this xsi:type="ManagedObjectReference" type="ClusterComputeResource">domain-c22</_this>

            <spec xsi:type="ClusterConfigSpecEx">



                <info xsi:type="ClusterVmGroup">


                  <vm type="VirtualMachine" >vm-2261</vm>









      Error Message:


      Unable to find specified dynamic type &quot;ClusterVmGroup&quot;

      Specified dynamic type ClusterVmGroup is not a DataObject type.


      If I watch this call happen in Project Onyx using both the VI Client and PowerCLI the exact same call is pretty much being made, without failure. Can anyone provide an explanation on how format my SOAP to make this work? I use onyx for similar operations making SOAP calls and never have problems. I've reviewed the reference API docs, and it looks right...


      Kind Regards

        • 1. Re: Execute SOAP request to Add Virtual Machine to DRS Group
          shill81 Lurker

          I spent almost a day figuring this out: You need to set the API version in the HTTP header:


          SOAPAction: "urn:vim25/6.5"


          If you don't do that you end up with an older API version, which does not support the neccesary datatypes.


          POST https://<hostname>/sdk/vimService HTTP/1.1

          Accept-Encoding: gzip,deflate

          Content-Type: text/xml;charset=UTF-8

          SOAPAction: "urn:vim25/6.5"


          Content-Length: 681

          Host: <host>

          Connection: Keep-Alive

          User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

          Cookie: vmware_soap_session="<sessionkey>"

          Cookie2: $Version=1


          <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:vim25" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">




                   <urn:_this type="ClusterComputeResource">domain-c28</urn:_this>

                   <urn:spec xsi:type="ClusterConfigSpecEx">



                      <info xsi:type="ClusterVmGroup">