VMware Cloud Community
Bordon01
Contributor
Contributor
Jump to solution

REST start a Workflow with Input-Parameter VC:VirtualMaschine

Hey everybody,

i'm trying to start a workflow via a REST-POST-Call to Start a Virtual Maschine.

I use the HTTP ContentType "text/XML" and call via

"https://{vmhost}:{port}/vco/api/workflows/{workflowID}/executions/ 

and send the following httpBody:

<execution-context xmlns="http://www.vmware.com/vco">

<parameters>

<parameter name="vm" type="VC:VirtualMaschine">

<VC:VirtualMaschine>vm04711</VC:VirtualMaschine>

</parameter>

</parameters>

</execution-context> 

but there are come back a Error-Message

"REST: HTTP POST request failed with error 400 (Bad Request)"

I don't know, if there parameters are in the httpBody are correct. The Input-Parameter in the Workflow has the Name "vm"  with the type "VC:VirtualMaschine".

In the Doc http://pubs.vmware.com/orchestrator-70/topic/com.vmware.ICbase/PDF/vrealize-orchestrator-70-develop-...

there is an example with string but with an VC:VirtualMaschine-Type, i don't know who are the Syntax is.

Could someone help me - thanks a lot

greetings

Reply
0 Kudos
1 Solution

Accepted Solutions
Bordon01
Contributor
Contributor
Jump to solution

I've solved the Problem.

In the http Body, i don't get the IP of the vCenter-Server it is the DNS-Name. After that it works.

The id of the workflow was ok and also the id of the vm.

Thanks a lot for your support

View solution in original post

9 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

Here is a sample request body:

<execution-context xmlns="http://www.vmware.com/vco">

  <parameters>

    <parameter name="vm" type="VC:VirtualMachine">

      <sdk-object type="VC:VirtualMachine" id="10.23.7.15/vm-8731" />

    </parameter>

  </parameters>

</execution-context>


10.23.7.15 above is the address of the vCenter where the virtual machine vm-8731 is managed.


Also, a few other remarks:


  • Content-Type and Accept headers - use application/xml instead of text/XML
  • VirtualMaschine should be spelled VirtualMachine
Reply
0 Kudos
Bordon01
Contributor
Contributor
Jump to solution

Thanks for your quick Response. When i modify your request Body to my Settings then the workflow start, but in the log of Orchestrator come back:

TypeError: Cannot read property "powerState" from undefined

Do you know what happend?

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Which workflow are you trying to start? Is it an out-of-the-box workflow that comes with vRO, or is it your custom workflow? Also, which vRO version do you use?

Reply
0 Kudos
Bordon01
Contributor
Contributor
Jump to solution

It's a vRO-Workflow (Start virtual machine and wait) and i use vRO-Version 6.0.3

Reply
0 Kudos
Bordon01
Contributor
Contributor
Jump to solution

This is the Workflow "Start virtual machine and wait":

pastedImage_0.png

In the Main-Workflow there are an Error with the Value:

pastedImage_1.png

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

This error means the virtual machine with such ID cannot be found on the specified vCenter.

Could you provide the exact request body plus the exact command line you use to start the workflow?

Also, could you try to execute a GET request with a URL like the following, to see if the virtual machine can be found?

https://10.23.2.19:8281/vco/api/catalog/VC/VirtualMachine/10.23.7.15%252Fvm-8731/

in the above URL, 10.23.2.19 is the vRO server, 10.23.7.15 is the vCenter server, and vm-8731 is the ID of the virtual machine.

Reply
0 Kudos
Bordon01
Contributor
Contributor
Jump to solution

pastedImage_0.png

This is the request Body:

<execution-context xmlns="http://www.vmware.com/vco"> 

<parameters> 

<parameter name="vm" type="VC:VirtualMachine"> 

<sdk-object type="VC:VirtualMachine" id="172.31.3.22/vm-730"/> 

</parameter> 

</parameters> 

</execution-context>

When I start manually the Workflow it works. But in the Value-Parameter, i get back the Name of the Virtual Machine not the id!?

pastedImage_1.png

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

This workflow ID (8492...) is not the ID of the stock workflow 'Start virtual machine and wait'. Did you duplicate it?

REST API calls and manually executing the workflow via vRO Client UI are 2 completely different things.

In the value column, you are seeing the display value of the object; it is normal to see a name and not an ID there.

Also, were you able to find the virtual machine by making a GET request with the catalog API I provided in my previous post? If it doesn't find anything, then your REST call to start the workflow also won't be able to find the virtual machine. Most likely, you are not constructing the proper command line.

Reply
0 Kudos
Bordon01
Contributor
Contributor
Jump to solution

I've solved the Problem.

In the http Body, i don't get the IP of the vCenter-Server it is the DNS-Name. After that it works.

The id of the workflow was ok and also the id of the vm.

Thanks a lot for your support