internal XElement TeamCityRestApiCall(string endpointUrl) { if (_versionInfo == null && !endpointUrl.EndsWith(TeamCityEndpoint.Server)) { Authenticate (); } endpointUrl = TeamCityEndpoint.GetEndPoint (endpointUrl, _versionInfo); try { Console.WriteLine ("HTTP request to " + endpointUrl); using (TimeOutWebClient wc = new TimeOutWebClient(TimeoutSeconds)) { string userName = _configuration.UseGuestLogin ? "guest" : _configuration.UserName; string password = _configuration.UseGuestLogin ? "" : _configuration.Password; wc.SetCredentials(userName, password); string url = _configuration.ServerUrl + endpointUrl; string resultXml = wc.DownloadString(url); return XElement.Parse(resultXml); } } catch(Exception ex) { return null; } }
internal string TeamCityHttpCall(string endpointUrl) { try { Console.WriteLine ("HTTP request to " + endpointUrl); using (TimeOutWebClient wc = new TimeOutWebClient(TimeoutSeconds)) { string userName = _configuration.UseGuestLogin ? "guest" : _configuration.UserName; string password = _configuration.UseGuestLogin ? "" : _configuration.Password; wc.SetCredentials(userName, password); string url = _configuration.ServerUrl + endpointUrl; string result = wc.DownloadString(url); return result; } } catch(WebException) { return null; } }