Unable to Launch build from Web App Using Rest API


I am writing a web app to allow team members to launch builds in TeamCity. I would like to accomplish this by issuing AJAX calls from the single page web app client to the Team City server.
After going through existing documentation on rest api and CORS, I am still having problems. Specifically, when I issue a POST from the web app to launch a build configuration on the build queue, Chrome, IE10, and Firefox will all send a CORS pre-flight OPTIONS request to TC server. The TC server responds with 401 Unauthorized.

I have set internal properties:


The CORS OPTIONS url is sent to http://MyTeamCity:8080/httpAuth/app/rest/buildQueue since that is where the initial POST is directed.

There is nothing in the rest api build log regarding this request. Does TeamCity log these incoming CORS OPTIONS preflight requests?

In general, more detailed examples in the Team City documentation on how to control and monitor Team City builds from a single page web app  would be extremely helpful.



1 comment
Comment actions Permalink

I finally got this to work and was able to trigger a build from a web app residing in a separate domain from the TeamCity Server via CORS.

These are the TeamCity  CORS internal properties definitions:



The POST is directed to http://MyTeamCityServer/app/rest/latest/buildQueue

with Authorization header and content type set as follows:

Authorization: Basic <base64 encoded username:password>

Content-Type: application/xml

and POST body: <build><buildType id="<MyBuildConfiguration"/></build>


Please sign in to leave a comment.