erwabovm
Contributor
Contributor

vRO REST API for Executing Workflows

I'm trying to trigger a workflow from the API. I have used the built in generator and I have the correct API call for a simple workflow:

https://10.10.10.76:8281/vco/api/workflows/65933170-a081-4cb2-89cb-5374b49a0a21/executions

However I am getting this:

pastedImage_0.png

Any ideas?

Thanks!

0 Kudos
18 Replies
Burke-
VMware Employee
VMware Employee

Have you set the authentication header?

This old walk-through I did still applies with very little/no change required for current versions: http://bit.ly/restvco ( https://www.vcoteam.info/articles/learn-vco/268-how-to-use-the-rest-api-to-start-a-workflow.html )

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
erwabovm
Contributor
Contributor

I have seen that, however its using that REST API plugin. 

What I would like to do is fire off a workflow out of the Service Now self service portal...which will let you assign an API Call URL to a button for a user to click on.

Im just not sure how to build the back end piece. Also the workflow requires 4 user inputs, so I wasnt sure if the API web Call would pop open the window to request input parameters for the workflow

0 Kudos
Burke-
VMware Employee
VMware Employee

Ah, ok - I don't know the ServiceNow side so not sure what you have available over there. My article is note using an API plug-in, it is simply using a generic tool to make a call to the vRealize Orchestratro REST API. The only API available for vRO is REST based so anything capable of making a call to a REST API should be able to launch a vRO workflow assuming you have the correct headers set, content format, and endpoint url (Your original post looks like you have this last bit set fine).

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
erwabovm
Contributor
Contributor

Well Swagger (from the VRO local portal) generates this for me: I just have no idea what goes in here or how to pass authentication (which is LDAP) I read some docs, but I dont see any examples. Just hitting the URL SHOULD fire off the workflow, but clearly not happening LOL

curl -X POST --header 'Content-Type: application/xml' --header 'Accept: text/html' -d '{
"parameters": [
{
"description": "string",
"encryptValue": true,
"name": "string",
"scope": "local",
"type": "string",
"updated": true,
"value": {
"objectType": "string"
}
}
]
}' 'https://10.10.10.76:8281/vco/api/workflows/65933170-a081-4cb2-89cb-5374b49a0a21/executions'

0 Kudos
erwabovm
Contributor
Contributor

Your examples in XML and JSON are also hard coding the parameters as well? I need to ask the user for the 4 input parameters. How would that be accomplished?

0 Kudos
Burke-
VMware Employee
VMware Employee

That is dependent on the system calling and how it allows you to form XML or 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
Burke-
VMware Employee
VMware Employee

This looks wrong... if using a JSON content as shown in your post then the Content-Type header should be application/json

Also, there is no authentication in that example either... no interactive or set header being shown...

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
erwabovm
Contributor
Contributor

Well thats correct cuz I select the application/XML template, not the JSON one.

"Also, there is no authentication in that example either... no interactive or set header being shown"

Yes, also correct....because I dont know how to set those items. Thats kinda what I was looking for. This is my first time attempting the REST API for VRO

0 Kudos
iiliev
VMware Employee
VMware Employee

In the curl command above, you need to add the parameter

  --user myuser:mypassword

(replacing myuser and mypassword with the actual credentials you use to authenticate in vRO)

Also, the header 'Accept:text/html' is wrong; for the result of this API you'd want to receive response in XML or JSON format, so the proper header would be 'Accept: application/xml' or 'Accept: application/json'

0 Kudos
erwabovm
Contributor
Contributor

Well that Curl Command was generated by Swagger in VRO. I dont know how to USE that command....or what to use to edit it and fire it off for testing.

Im brand new to the REST API model and I dont know how to use any of this. It doesnt seem that difficult, but I dont really know how it all goes together.

0 Kudos
Burke-
VMware Employee
VMware Employee

If you prefer not to specify the password in plain text, you could base64 encode it then set your authentication header as follows:

curl --header 'Authorization: Basic ENCODEDPW_HERE'

While I'm sure there are command line ways of getting the base64 encoded text for a user/password combination, I simply use Postman to do it for me by setting authorization to Basic, providing a username and password, then viewing the Authorization header that gets set.

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
erwabovm
Contributor
Contributor

I tried the Rest Client of Firefox with basic auth and I get

pastedImage_0.png

So what would the Curl text look like for http authentication? (which is grayed out for me)

pastedImage_1.png

0 Kudos
erwabovm
Contributor
Contributor

Also Im curious about this because in the vro Control center, its using Vshpere which is LDAP

pastedImage_0.png

0 Kudos
Burke-
VMware Employee
VMware Employee

Please check your private message here in the communities.

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

What was the outcome to this, I am having a similar issue ?
0 Kudos
kumarsenthild
Enthusiast
Enthusiast

I am also facing same issue.

Regards Senthil Kumar D
0 Kudos
iiliev
VMware Employee
VMware Employee

I'm a bit confused. As there were several messages in this thread with slightly different issues, could you clarify what exactly is not working in your case and how are you calling the vRO API?

0 Kudos
jacobpeek
Contributor
Contributor

I add an additional --header "Authorization:  Basic myBase64EncryptedUserIdandPassword"

curl -X POST --header 'Authorization: Basic cccbbbcjjcwnqnwjloveovjreovnejrvnelvljkeqv' --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{

0 Kudos