How to trigger build from JavaScript (REST API)


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}

                dataType: "json",
                contentType: "application/json",
                success: function(){console.log(data);}

Am I doing something wrong? "buildQueueUrl" has the value of "/httpAuth/app/rest/buildQueue"

Comment actions Permalink

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.

Comment actions Permalink

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.


Please sign in to leave a comment.