Is it possible for getting access to TeamCity REST API and receive JSON response using jQuery AJAX?

I can receive proper response from TC using tool like Postman for doing ajax requests, but I am struggling to do the same using jQuery.

I have some simple code:

      url: TC_CONFIG.url + "httpAuth/app/rest/builds/",
      dataType: "jsonp",
      contentType: "application/json",
      method: "GET",
      success: function() {

And I'm struggling with it, because I have either error:

Origin http://localhost:8500 is not allowed by Access-Control-Allow-Origin.

or I receive response in XML (which is not suitable for me, as on client side I don't want to mess with xml sh*t)

Reason I do that is to create some monitoring application written in AngularJS + jQuery to show status of TeamCity builds.


Comment actions Permalink
Hi Peter,

> Origin http://localhost:8500 is not allowed by Access-Control-Allow-Origin.

That is related to CORS (cross domain requests) browser limitations, not to XML/json or jquery.

I'd suggest to deploy your code on the same domain as TeamCity runs on to exclude that from the equation.
If you are proficient with HTTP/requests, etc. you can try to use CORS with the API.
Comment actions Permalink

Funny thing: I had already CORS configured on server by this line in configuration:*

but I think it doesn't change anything.

As you suggested I tried also upload my website on the same machine as TC is hosted by. Result was unfortunately the same.

XMLHttpRequest cannot load http://localhost:9999/httpAuth/app/rest/builds/. Origin http://localhost is not allowed by Access-Control-Allow-Origin.

Any more ideas? :>


Please sign in to leave a comment.