VMware {code} Community
jake_robinson_b
Hot Shot
Hot Shot

Instantiate vApp error: (400) Bad Request [SOLVED]

I am attempting to instantiate a vApp from a template, and I am getting a 400 error. I am basically cutting and pasting the example code from the programming guide, and changing out the URIs and names. Details are below, but I changed the names/IDs for security purposes.

POST https://VCD/api/v1.0/vdc/12345/action/instantiateVAppTemplate

Content-Type: application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml

<InstantiateVAppTemplateParams name="Jake Test" xmlns="http://www.vmware.com/vcloud/v1" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" >
<Description>Test Instantiate</Description>
<InstantiationParams>
<NetworkConfigSection>
<ovf:Info>Configuration parameters for vAppNetwork</ovf:Info>
<NetworkConfig networkName = "isolation">
<Configuration>
<ParentNetwork href="https://VCD/api/v1.0/network/12345"/>
<FenceMode>bridged</FenceMode>
</Configuration>
</NetworkConfig>
</NetworkConfigSection>
</InstantiationParams>
</InstantiateVAppTemplateParams>
Jake Robinson VCP, vExpert - geekafterfive.com - Twitter: @jakerobinson
Reply
0 Kudos
9 Replies
Todor_Todorov
Hot Shot
Hot Shot

Hi,

Can you post some more details about the returned error - error message, stack trace (if available)?

Regards,

Todor

Reply
0 Kudos
jake_robinson_b
Hot Shot
Hot Shot

Here's the error message:

"The remote server returned an error: (400) Bad Request."

That's the only info I have, unless you can tell me how to enable tracing for system.net.webrequest in powershell...

All of my other POSTs work fine, so I am guessing it is a problem with the XML...

Jake Robinson VCP, vExpert - geekafterfive.com - Twitter: @jakerobinson
Reply
0 Kudos
Todor_Todorov
Hot Shot
Hot Shot

Can you look into <cloud_dir>/logs/container-debug.log to see for any errors which occurred in the same timeframe?

jake_robinson_b
Hot Shot
Hot Shot

vcloud-container-debug.log has a few of these:

...

[org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'deploy'. One of '{"http://www.vmware.com/vcloud/v1":VAppParent, "http://www.vmware.com/vcloud/v1":InstantiationParams, "http://www.vmware.com/vcloud/v1":Source}' is expected.]

...

Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'deploy'. One of '{"http://www.vmware.com/vcloud/v1":VAppParent, "http://www.vmware.com/vcloud/v1":InstantiationParams, "http://www.vmware.com/vcloud/v1":Source}' is expected.

Let me know if this is enough, or if you need the full trace.

Jake Robinson VCP, vExpert - geekafterfive.com - Twitter: @jakerobinson
Reply
0 Kudos
Todor_Todorov
Hot Shot
Hot Shot

Do you have a <deploy> element in your request? You should not have one as the error describes.. Also, in the request you sent in your first post, there's no deploy element.

Reply
0 Kudos
jake_robinson_b
Hot Shot
Hot Shot

According to the Programming guide:

deploy 0 1 xs:boolean True if the vApp should be deployed after
instantiation. Defaults to false

Regardless, I have tried it both ways, with and without the deploy element.

Jake Robinson VCP, vExpert - geekafterfive.com - Twitter: @jakerobinson
Reply
0 Kudos
Todor_Todorov
Hot Shot
Hot Shot

'deploy' is an attribute of the <InstantiateVAppTemplateParams> element, not an element. Do you get the same error when you remove 'deploy'?

Reply
0 Kudos
jake_robinson_b
Hot Shot
Hot Shot

So, my code was a little different than what I originally posted, and it did have the deploy element.

Just to get all the XML stuff out of the way, I did a validation against the XSD, and it found 2 problems. :smileygrin:

After fixing those, I received another 400 error stating that the creation of this vApp would violate the disk quota. Fixed that too. (Figured out how to turn on System.Net Tracing for powershell! :smileygrin:)

Now when I try to Instantiate the vApp template, I am getting a 400 error telling me that: "The vCD entity network "internet02" specified for VM "jeos" does not exist."

Now, I am unsure what to do about this, because the network does in fact exist, and other VMs are running on it just fine. Just to make sure I wasn't crazy, I tried another template with another netowork and it did the same thing.

Jake Robinson VCP, vExpert - geekafterfive.com - Twitter: @jakerobinson
Reply
0 Kudos
jake_robinson_b
Hot Shot
Hot Shot

Okay, I figured it out. The networkName has to match the name of the org network in the vApp Template. Cloned successfully!

Jake Robinson VCP, vExpert - geekafterfive.com - Twitter: @jakerobinson
Reply
0 Kudos