How to trigger build from JavaScript (REST API) Follow
Hello,
I'm trying to trigger a build from JavaScript. When I try the following code, I get "400 (Bad Request)"
var data = {
buildType: {id: buildTypeId}
}
console.info(data);
$.ajax({
method:"POST",
url:buildQueueUrl,
data:data,
dataType: "json",
contentType: "application/json",
success: function(){console.log(data);}
});
Am I doing something wrong? "buildQueueUrl" has the value of "/httpAuth/app/rest/buildQueue"
Please sign in to leave a comment.
I was supposed to pass "jsonp" instead of "json" to dataType. I changed the code and tried it out, but I got the same result.
Hi Hayato,
jsonp is not supported, only application.xml and application/json are.
I'd recommend getting the right request with a sinple tool like curl or some other request sender and then making sure JavaScript code sends the same request.
Examples, though with XML can be found in the doc.