dlarosa11
Enthusiast
Enthusiast

executing workflow with REST

I've made this call from a python script using requests.post and I get a 200 return status and a list of the executions (just like I get when I do a requests.get with the same url).

Inputs:

params = {'workflowId': 'a81f071d-8bd0-4f94-a4b0-8af4c030d0b6'}

data = {'parameters': [{'name': 'criteria', 'type': 'string', 'value': {'string': {'value': 'BLUEDC12A'}}}]}

URL

https://vm-prd01vro:8281/vco/api/workflows/a81f071d-8bd0-4f94-a4b0-8af4c030d0b6/executions?workflowI...

Return:

Status=200

Reponse={'relations': {'total': 1, 'link': [{'href': 'https://vm-prd01vro:8281/vco/api/workflows/a81f071d-8bd0-4f94-a4b0-8af4c030d0b6/', 'rel': 'up'}, {'href': 'https://vm-prd01vro:8281/vco/api/workflows/a81f071d-8bd0-4f94-a4b0-8af4c030d0b6/executions/', 'rel': 'add'}, {'attributes': [{'value': '2c91e4a35b8cb581015b8d0b774a0101', 'name': 'id'}, {'value': '2017-04-20T16:26:30.603-04:00', 'name': 'startDate'}, {'value': '2017-04-20T16:26:32.627-04:00', 'name': 'endDate'}, {'value': 'd104647@corp.unifirst.com', 'name': 'startedBy'}, {'value': 'completed', 'name': 'state'}, {'value': 'unf_Get virtual machines by name', 'name': 'name'}, {'name': 'currentItemDisplayName'}], 'href': 'https://vm-prd01vro:8281/vco/api/workflows/a81f071d-8bd0-4f94-a4b0-8af4c030d0b6/executions/2c91e4a35...', 'rel': 'down'}]}}

I have a feeling that my request body is not correct.  What is the correct format of the body?  Where is this documented?  Is this where I specify input parameters for the workflow?

Thanks for any help

Dom

Tags (1)
9 Replies
Burke-
VMware Employee
VMware Employee

Why does your url have ?workflowID=REPEATEDWORKFLOWID

The workflow id is already in the url.

The 200 return status is good - what exactly is your problem here?

have you read my post: http://bit.ly/restvco ? http://bit.ly/pythonvco ?

or checked my repo?

http://bit.ly/vroClientScripts

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
iiliev
VMware Employee
VMware Employee

Status 200 OK is not OK when starting a workflow; the expected success status code for this API call is 202 Accepted

One issue with your inputs is that you are using single quotes '. JSON strings should use double quotes ".

BTW, with an incorrect request body you should be getting status code 400. I'm not sure why you are getting 200; perhaps your client does something weird like falling back to GET. Could you try with some other REST client, eg. curl ?

dlarosa11
Enthusiast
Enthusiast

The 200 is not good.  The documentation doesn't even say what 200 means.  202 is what I'm looking.  What's wrong is that the workflow does not run.  The worfkflowId is in the request because that is what the documentation says to do.  I cannot get to you posts because my company blocks it.

0 Kudos
dlarosa11
Enthusiast
Enthusiast

I tried two rest Google plugins and the python script.  I'll try

0 Kudos
Burke-
VMware Employee
VMware Employee

right, right.. sorry about that... was a bit rushed when I did the reply. Indeed 202 is what is needed. With regards to your company blocking bit.ly - bummer, here are the expanded URLs:

https://www.vcoteam.info/articles/learn-vco/268-how-to-use-the-rest-api-to-start-a-workflow.html

https://www.vcoteam.info/articles/learn-vco/295-how-to-use-python-to-start-an-orchestrator-workflow....

GitHub - burkeazbill/vroClientScripts: REST Client Script examples

Here's an extra article that is also quite helpful:

Introducing Swagger UI on vRO 7.0.1

Between Ilian's response regarding the quotes, and you looking over these linked resources, you should be on your way to successfully executing the workflows via API.

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
dlarosa11
Enthusiast
Enthusiast

I got to your posts on my phone and they are most informative.  Always thankful for folks like you that take the time to create such tutorials.

My problem persists.  I tried curl and got the same results.  Not even sure how I would include a body or post with curl so I need to look into that more.

Tx again.  I'll keep trying.

0 Kudos
iiliev
VMware Employee
VMware Employee

Here is curl command line to start the workflow (you need to provide valid vRO username/password credentials with -u parameter):

curl -ikv -u user:pass -H "Accept: application/json" -H "Content-Type: application/json" -X POST https://vm-prd01vro:8281/vco/api/workflows/a81f071d-8bd0-4f94-a4b0-8af4c030d0b6/executions -d @request.json

The request body for the command above (-d parameter) is stored in file request.json. It's content should be something like (your input data with quotes replaced by double quotes):

{

  "parameters": [{

  "name": "criteria",

  "type": "string",

  "value": {

  "string": {

  "value": "BLUEDC12A"

  }

  }

  }]

}

dlarosa11
Enthusiast
Enthusiast

You guys are awesome.  I got it to work in my google plugin and with curl.  Just need to get the python script working.  Must be something funky in the requests package that is not posting correctly.  Thanks again for the help.

0 Kudos
dlarosa11
Enthusiast
Enthusiast

I was missing the /vco after the server name in my request url.  I guess the request must have gotten redirected and somehow lost it's mind and forgot to post rather than get.  By adding the /vco it works fine.  Thanks again guys.  The examples are awesome.

0 Kudos