VMware Cloud Community
CalmCloud
Enthusiast
Enthusiast
Jump to solution

Execute a workflow with REST API

Hi All,

I am not able to execute the workflow with REST api.

POST https://<<HOST>>:<<PORT>>/api/workflows/94dd5f20-c190-4023-a0a7-1589c46f3792/executions/

following is the response. VCO does not have any work flow runs so I assumed nothing was executed. I can run https://wxpcpvcd006a:8281/api/workflows/f29ebe52-27b2-42d1-84f1-6ecfb939326c to get all the info about the workflow. Any help appreciated.

{

    "relations": {

        "total": 0,

        "link": [

            {

                "href": "https://wxpcpvcd006a:8281/vco/api/workflows/94dd5f20-c190-4023-a0a7-1589c46f3792/",

                "rel": "up"

            },

            {

                "href": "https://wxpcpvcd006a:8281/vco/api/workflows/94dd5f20-c190-4023-a0a7-1589c46f3792/executions/",

                "rel": "add"

            }

        ]

    }

}

0 Kudos
1 Solution

Accepted Solutions
Burke-
VMware Employee
VMware Employee
Jump to solution

just enter opening/closing curly braces as your json content:

{}

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter

View solution in original post

0 Kudos
11 Replies
Burke-
VMware Employee
VMware Employee
Jump to solution

My article steps you through the process of calling workflows with REST: http://bit.ly/restvco - you should certainly see a workflow execution when you have completed the call properly.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
CalmCloud
Enthusiast
Enthusiast
Jump to solution

Hi Burke,

I followed your blog.  It works fine with GET request like getting workflow executions, definition etc. It does not work for running workflows - POST request. I noticed POST to run workflow get 301 redirect for GET. I am running VCO 5.5.1 version.


Attached are screenshots.

0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

In vCO 5.5.x and up, the URLs of REST API requests have been changed a bit

Instead of

  https://[host]:[port]/api/...

they now look like

  https://[host]:[port]/vco/api/...

That's one of the reasons you get 301 redirects.

CalmCloud
Enthusiast
Enthusiast
Jump to solution

I have tried /vco ,it throws 400 error with.

VCO was recently upgraded  to 5.5.1.

<html>

   <head>

      <meta content="HTML Tidy for Java (vers. 26 Sep 2004), see www.w3.org" name="generator"/>

      <title>VMware vFabric tc Runtime 2.9.5.SR1/7.0.50.C.RELEASE - Error report</title>

      <style type="text/css">&lt;!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style>

   </head>

   <body>

      <h1>HTTP Status 400 -</h1>

      <hr noshade="noshade" size="1"/>

      <p>

         <b>type</b>

         Status report

      </p>

      <p>

         <b>message</b>

      </p>

      <p>

         <b>description</b>

         <u>The request sent by the client was syntactically incorrect.</u>

      </p>

      <hr noshade="noshade" size="1"/>

      <h3>VMware vFabric tc Runtime 2.9.5.SR1/7.0.50.C.RELEASE</h3>

   </body>

</html>

0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Which means your POST request body is not properly formatted. Could you show the exact XML or JSON body content? 

0 Kudos
CalmCloud
Enthusiast
Enthusiast
Jump to solution

I want to get simple workflow working so workflow does not have any inputs so there is no json body.

Attached is chrome plugin postman. It shows only get and delete are allowed.

0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Yes, POST is not supported on https://[host]:[port]:8281/vco/api/workflows/[workflow-id]    (the URL I see on the screenshot)

To start the workflow, you need to POST to the following URL

   https://[host]:[port]:8281/vco/api/workflows/[workflow-id]/executions


0 Kudos
CalmCloud
Enthusiast
Enthusiast
Jump to solution

I get same error.

I might have to update REST plugin. I will update after that.

0 Kudos
Burke-
VMware Employee
VMware Employee
Jump to solution

Even a simple workflow with Zero inputs still requires a body when doing a post...

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos
Burke-
VMware Employee
VMware Employee
Jump to solution

just enter opening/closing curly braces as your json content:

{}

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos
CalmCloud
Enthusiast
Enthusiast
Jump to solution

Thanks Burke and llian

0 Kudos