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);
}
});
}