Пример #1
0
        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;
            }
        }
Пример #2
0
        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;
            }
        }