예제 #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 byte[] TeamCityHttpDataCall(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;
                    var result = wc.DownloadData(url);
                    return result;
                }
            }
            catch(WebException)
            {
                return null;
            }
        }