REST API / AJAX JSON
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:
$.ajax({url: TC_CONFIG.url + "httpAuth/app/rest/builds/",dataType: "jsonp",contentType: "application/json",method: "GET",success: function() {console.log(data);}});
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.
Help
Please sign in to leave a comment.
> 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.
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.
Any more ideas? :>