virtualportal
Enthusiast
Enthusiast

Execute Workflow - vCO 5.1 API

Jump to solution

Hi I am having trouble executing a Workflow using the new VCO 5.1 RESTful API. Wondering if you can help.

I am trying to execute a workflow called "HelloAPI", which simply takes one input parameter 'name' which is then outputted to the System.log.

I am getting the error:

The request sent by the client was syntactically incorrect ().

Status Code: 400

When trying to execute the following POST to the API.

curl -k --user vcoadmin:vcoadmin -H "Content-Type:application/xml" -X POST -d request.xml https://<vco-server>:8281/api/workflows/3572df5e-f1ba-4ac4-b7f6-ea3b2cf4bc60/executions/

Request.xml looks like:

<?xml version="1.0" encoding="UTF-8"?>
<vco:execution-context xmlns:vco="http://www.vmware.com/vco" xmlns="vco">
  <vco:parameters>
    <vco:parameter name="name" type="string" description="" scope="local">
      <vco:string>Curl</vco:string>
    </vco:parameter>
  </vco:parameters>
</vco:execution-context>

I initially had problems due to the Content-Type, but managed to resolve that by sending it in the header. To me, this XML looks how the execution context should according to the API Docs. Any help would be much appreciated.

Thanks

Steve

0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee

Hi Steve,

POST-ing to .../workflows/{id}/presentation/instances/ creates a new presentation execution which is useful if you want to validate input parameters. If you are confident that they are valid (as in your example) you don't need to start a presentation execution; you can directly start the workflow execution.

As I said in my previous response, your first attempt was almost correct except the curl command line syntax for specifying request file - it should be

-d @request.xml


Thanks,

Ilian

View solution in original post

0 Kudos
8 Replies
admin
Immortal
Immortal

Have you try to set the request.xml in "" ? I had to call the presentation validation before...

Sent from iPhone | Christian Johannsen | cjohannsen@vmware.com<mailto:cjohannsen@vmware.com> | +49(0)15209359275

Am 13.09.2012 um 17:46 schrieb virtualportal <communities-emailer@vmware.com<mailto:communities-emailer@vmware.com>>:

VMware Communities<http://communities.vmware.com/index.jspa>

Execute Workflow - vCO 5.1 API

created by virtualportal<http://communities.vmware.com/people/virtualportal> in Orchestrator - View the full discussion<http://communities.vmware.com/message/2114079#2114079

0 Kudos
virtualportal
Enthusiast
Enthusiast

Hi Christian,

Just tried it with the request.xml in "" and still no luck..I did notice a typo in my original xml but that didnt solve it either so have updated the original post with the correct xml.

Steve

0 Kudos
admin
Immortal
Immortal

Here is what works for me:

curl -i -k -H "content-type: text/xml" -u User:Pass --upload-file "in-parameter.xml" -X POSThttps://myVcoServer:8281/api/workflows/9B808080808080808080808080808080C6848080013049428390141bc5149...

Before that I used:

curl -i -k -H "Accept:application/*+xml" -u User:Pass -X GET https://myVcoServer:8281/api/users

best regards

Christian

igorstoyanov
VMware Employee
VMware Employee

- The vCO REST API has a documentation that could be access at https://your-vco-ip:8281/api/docs/

I guess you have already done this but just to make sure people reading this thread are aware.

- Next, there is a Java Rest Client and a few examples that could be downloaded from "Files and Libraries": https://your-vco-ip:8281/api/docs/downloads.html

- Also, as Christian said, the recommendation should be to execute workflows via the Workflow Presentation Service since this will provide input validation and collect all error.

- Finally, looking at your xml request, I don't see anything wrong. And by using the Java Rest Client, I was able to execute the same operation.

This is my debug output:

DEBUG headers - >> POST /api/workflows/2ebe44e3-897f-44e5-aeff-f8da104f6ac8/executions/ HTTP/1.1

DEBUG headers - >> Accept: application/json

DEBUG headers - >> Content-Type: application/xml

DEBUG headers - >> Content-Length: 223

DEBUG headers - >> Host: ..........:8281

DEBUG headers - >> Connection: Keep-Alive

DEBUG headers - >> User-Agent: Apache-HttpClient/4.1.2 (java 1.5)

DEBUG headers - >> Authorization: Basic dmNvYWRtaW46dmNvYWRtaW4=

DEBUG wire - >>

"<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

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

          <parameters>

             <parameter name="name" type="string">

                  <string>TestName</string>

             </parameter>

          </parameters>

      </execution-context>"

DEBUG wire - << "HTTP/1.1 202 Accepted"

DEBUG wire - << "Location: https://.......:8281/api/workflows/2ebe44e3-897f-44e5-aeff-f8da104f6ac8/executions/ff80808139c26a0e0..."

DEBUG wire - << "ETag: "0d41d8cd98f00b204e9800998ecf8427e""

DEBUG wire - << "Content-Length: 0"

DEBUG wire - << "Date: Fri, 14 Sep 2012 03:45:20 GMT"

DEBUG wire - << "Server: vCO Server"

DEBUG wire - << ""

The only thing that I see to be different is that the parameter element doesn't have "description" and "scope" attrubutes. Probably, try removing them (they are optional anyway although not very likely to be the issue).

Also, it is using the default namespace but not sure this could be the issue.

A third option could be with something in the header that you are missing or the way how you create the request. Probably, monitoring the trafic could provide some clue.

Hope this is helpful.

Thanks,

Igor.

Visit http://blogs.vmware.com/orchestrator for the latest in Cloud Orchestration.
0 Kudos
iiliev
VMware Employee
VMware Employee

Hi Steve,

Your curl command line is not correct. To pass the content of 'request.xml' file as POST body, you need to use the option '-d @request.xml'. Note the extra @ character before file name; without it, the name of the file is passed in the reuest body instead of the file content.

Hope this helps.

Thanks,

Ilian

virtualportal
Enthusiast
Enthusiast

Hi all,

Maybe I am missing something but changing the URI to /presentation/instances seemed to give me a 200 response Smiley Happy However I cannot see any valid workflow runs in the orchestrator client. Is this a change with 5.1?

Here is the response I am getting (request.xml is the same as above):

curl -i -k -H "content-type: text/xml" -u vcoadmin:vcoadmin --upload-file "request.xml" -X POST https://192.168.1.91:8281/api/workflows/3572df5e-f1ba-4ac4-b7f6-ea3b2cf4bc60/presentation/instances
HTTP/1.1 100 Continue
HTTP/1.1 200 OK
ETag: "039a36e98e247baf1579629ce3c5a019d"
Content-Type: application/json;charset=UTF-8
Content-Length: 1311
Date: Mon, 24 Sep 2012 08:37:51 GMT
Server: vCO Server
{"valid":true,"parameters":[{"name":"name","value":{"value":"Curl","objectType":"string"},"type":"string"}],"startDate":1348475871758,"objectId":"3572df5e-f1ba-4ac4-b7f6-ea3b2cf4bc60","validationErrors":{"objectName":"","errorCount":0,"messageCodesResolver":{},"allErrors":[],"globalErrors":[],"fieldErrors":[],"nestedPath":"","globalErrorCount":0,"fieldErrorCount":0},"startedBy":"vcoadmin","name":"HelloAPI","id":"af8f5fad-8d0d-42e7-a9b7-9b3ef2c38220","steps":[{"elements":[{"fields":[{"fields":[],"value":{"value":"Curl","objectType":"string"},"type":"string","constraints":[],"decorators":[],"hidden":false,"displayName":"name","identifier":"name","description":"name","messages":[]}],"hidden":false,"messages":[]}],"hidden":false,"messages":[]}],"relations":{"links":[{"rel":"up","href":"https://192.168.1.91:8281/api/workflows/3572df5e-f1ba-4ac4-b7f6-ea3b2cf4bc60/presentation/"},{"rel":"cancel","href":"https://192.168.1.91:8281/api/workflows/3572df5e-f1ba-4ac4-b7f6-ea3b2cf4bc60/presentation/instances/..."},{"rel":"add","href":"https://192.168.1.91:8281/api/workflows/3572df5e-f1ba-4ac4-b7f6-ea3b2cf4bc60/executions/"}]},"href":"https://192.168.1.91:8281/api/workflows/3572df5e-f1ba-4ac4-b7f6-ea3b2cf4bc60/presentation/instances/..."}

The only thing I can think of is that this creates a presentation and then I have to run execute? Help much appreciated.

Thanks

0 Kudos
iiliev
VMware Employee
VMware Employee

Hi Steve,

POST-ing to .../workflows/{id}/presentation/instances/ creates a new presentation execution which is useful if you want to validate input parameters. If you are confident that they are valid (as in your example) you don't need to start a presentation execution; you can directly start the workflow execution.

As I said in my previous response, your first attempt was almost correct except the curl command line syntax for specifying request file - it should be

-d @request.xml


Thanks,

Ilian

0 Kudos
virtualportal
Enthusiast
Enthusiast

Thanks Ilian,

Apologies, I was trying the repsonse which stated I should call /presentation/instances. Looks like it worked once I changed the Syntax of the curl command.

Thanks for your answer Smiley Happy

Steve

0 Kudos