I am trying to use the TeamCity API to retrieve assembly data in JSON format for real-time display.
The display is a simple JavaScript application submitted as a web page in another domain to the TeamCity server. Therefore, this needs to be handled as a cross-lookup request (CORS).
My problem is that I cannot find a way to configure the jQuery ajax request to handle CORS and ask TeamCity to return a JSON response (not an XML response).
I tried various combinations of settings in my ajax object, with the latest version below:
return $.ajax({
url: url,
dataType: "jsonp",
type: "GET",
xhrFields: {
withCredentials:true
},
beforeSend: function(xhrObj){
xhrObj.setRequestHeader("Accept","application/json");
}
});
"url" includes TeamCity login credentials to satisfy Http Authentication.
, , - , , XML ( ).
, , ajax, JSON TeamCity?
Request URL:https://xxxxx/**httpAuth/app/rest/projects**?
callback=jQuery210040475526987574995_1394042043670&_=1394042043671
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:*/*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Cookie:__test=1; TCSESSIONID=F409E3C78BD3649E4DCA846DF5DD97F2;
RememberMe=-116716355^12
Host:builds.quillpinpoint.co.uk
Referer:http://localhost/orqaadmin/BuildMonitor/Index
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/33.0.1750.146 Safari/537.36
Query String Parametersview sourceview URL encoded
callback:jQuery210040475526987574995_1394042043670
_:1394042043671
Response Headersview source
Cache-Control:no-store
Content-Length:1009
Content-Type:application/xml
Date:Wed, 05 Mar 2014 17:55:41 GMT
Expires:Thu, 01 Jan 1970 00:00:00 GMT
Pragma:no-cache
Server:Microsoft-IIS/7.5
Set-Cookie:RememberMe=-xxxx
X-Powered-By:ARR/2.5
X-Powered-By:ASP.NET