cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
7125
Views
2
Helpful
0
Comments
Orf Gelbrich
Cisco Employee
Cisco Employee

This is an example on how to call a workflow via an API call.

The workflow has two inputs A1 and A2:

Screen Shot 2014-12-09 at 3.14.54 PM.png

Screen Shot 2014-12-09 at 3.13.21 PM.png

The workflow:

Screen Shot 2014-12-09 at 3.13.11 PM.png

The API call:

http://172.17.32.155/app/api/rest?formatType=json&opName=userAPISubmitWorkflowServiceRequest&opData={param0:"TestWorkFlowFromAPI",param1:{"list":[{"name":"A1","value":"Happy"},{"name":"A2","value":"Holidays"}]},param2:-1}

Screen Shot 2014-12-09 at 2.50.16 PM.png

Curl Example (Thank you Sangeeta Narang):

HTTP

curl  -v -X POST -H 'X-Cloupia-Request-Key:5CF4C115F0034B189616B2B8EBA0F220'  -g 'http://172.17.32.75/app/api/rest?formatType=json&opName=userAPISubmitWorkflowServiceRequest&opData={param0:"TestWorkFlowFromAPI",param1:{"list":[{"name":"A1","value":"Hello"},{"name":"A2","value":"World"}]},param2:-1}'


HTTPS

curl --insecure -v -X POST -H 'X-Cloupia-Request-Key:5CF4C115F0034B189616B2B8EBA0Fxxx'  -g 'https://172.17.32.75/app/api/rest?formatType=json&opName=userAPISubmitWorkflowServiceRequest&opData={param0:"TestWorkFlowFromAPI",param1:{"list":[{"name":"A1","value":"Hello"},{"name":"A2","value":"World"}]},param2:-1}'


NOTE:

For testing purpose use above command in insecure mode, otherwise install cacert in your system and use cert location in curl call using —cacert curl option.



In case there is a space in the Variable name:


curl --insecure -v -X POST -H 'X-Cloupia-Request-Key:C97B881CE6B94DFB930765F7AC408xxx'  -g 'https://172.31.234.127/app/api/rest?formatType=json&opName=userAPISubmitWorkflowServiceRequest&opData={param0:"AddUCSMvlanv1",param1:{"list":[{"name":"VLAN%20ID","value":"500"},{"name":"VLAN%20DESC","value":"CURLvlantest"}]},param2:-1}'



IN UCSD 6.5 THE API CHANGED:


curl --insecure -v -X POST -g -H 'X-Cloupia-Request-Key:F9E07E0FA6C3416BB4801075B7B5BXXX' -H 'Content-Type:application/x-www-form-urlencoded' -d 'formatType=json&opName=userAPISubmitWorkflowServiceRequest&opData={"param0":"TestWorkFlowFromAPI","param1":{"list":[{"name":"A1","value":"Hello"},{"name":"A2","value":"World"}]},"param2":-1}' https://172.16.50.51/app/api/rest

curl --insecure -v -X POST -g -H 'X-Cloupia-Request-Key:F9E07E0FA6C3416BB4801075B7B5Bxxx' -H 'Content-Type:application/x-www-form-urlencoded' -d 'formatType=json&opName=userAPISubmitWorkflowServiceRequest&opData={"param0":"CreateLOVPossibleDockerImagesV10","param1":{"list":[{"name":"Filenamewithpath","value":"/tmp/PossibleDockerImages"},{"name":"LovName","value":"PossibleDockerImages"}]},"param2":-1}' https://172.16.50.51/app/api/rest



Roll back example:


curl --insecure -v -X POST -H 'X-Cloupia-Request-Key:C97B881CE6B94DFB930765F7AC408xxx' -g 'https://172.31.234.127/app/api/rest?formatType=json&opName=userAPIRollbackWorkflow&opData={param0:140}'



The execution in the log file:

Screen Shot 2014-12-09 at 3.11.23 PM.png

The resulting e-mail with the transferred input values:

Screen Shot 2014-12-09 at 3.11.36 PM.png

In this example I am logged on as admin and am using the same session to make the API call.  This way I already have the cookie.

Obtaining the REST API Key

http://<UCSD_IP>/app/api/rest?formatType=json&opName=userAPIGetRESTAccessKey&opData={param0:"whiter"}

1. {

2.     "serviceResult": "CAB614BF89194336A4147FB8DDEF5638",

3.     "serviceError": null,

4.     "serviceName": "InfraMgr",

5.     "opName": "userAPIGetRESTAccessKey"

6. }

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links