This is an example on how to call a workflow via an API call.
The workflow has two inputs A1 and A2:
The workflow:
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}
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:
The resulting e-mail with the transferred input values:
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. }