I am trying to call a REST API post method to Cloudify.
I can run this successfully from commandline. Please see the command.
curl -X POST --header "Tenant: default_tenant" --header "Content-Type: application/json" -u admin:admin -d '{"deployment_id": "OSCreateVM", "workflow_id": "install"}' "http://xxxxxxxxx/api/v3.1/executions?_include=id"
However when I create an AJAX REST API call from my html, I am getting an "undefined" error. What went wrong here? Can someone help please?
function ajaxFunction(){
var parameters= {"deployment_id": "OSCreateVM", "workflow_id": "install"};
$.ajax({
type: "POST",
url: "http://xxxxxxxxx/api/v3.1/executions?_include=id",
headers: {
'Tenant': 'default_tenant',
'Content-Type': 'application/json'
},
data: JSON.stringify(parameters),
crossDomain: true,
dataType: "json",
username: "admin",
password: "admin",
success: function (responseData, status, jqXHR) {
alert ("Request for VM Creation is Succcessfully submitted");
},
error: function (request, status, error) {
// error handler
alert(request.responseText);
}
});
}
It's hard to understand what went wrong, syntactically it looks valid but "undefined" could be a lot of things.
I suggest you try to look at the events in the Cloudify manager Web-UI or CLI to understand what was undefined. If you use the Web-UI go to the deployments tab, look for OSCreateVM, click on it and look at the executions done to see more details.
If you do it via CLI run
cfy executions list -d OSCreateVMOnce you have the executions list run
cfy events list <ID_OF_THE_INSTALL_EXECUTION