From eb1ff79eb0dc09b82028424f226ad86035fae397 Mon Sep 17 00:00:00 2001 From: Alexander Fast Date: Tue, 8 Jan 2013 11:45:05 +0100 Subject: [PATCH] readded getraw method --- .../Connection/TeamCityCaller.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/TeamCitySharp/Connection/TeamCityCaller.cs b/src/TeamCitySharp/Connection/TeamCityCaller.cs index 32591109..b443a90b 100644 --- a/src/TeamCitySharp/Connection/TeamCityCaller.cs +++ b/src/TeamCitySharp/Connection/TeamCityCaller.cs @@ -225,6 +225,27 @@ private HttpClient CreateHttpClient(string userName, string password, string acc return httpClient; } + // only used by the artifact listing methods since i havent found a way to deserialize them into a domain entity + internal string GetRaw(string urlPart) + { + if (CheckForUserNameAndPassword()) + throw new ArgumentException("If you are not acting as a guest you must supply userName and password"); + + if (string.IsNullOrEmpty(urlPart)) + throw new ArgumentException("Url must be specfied"); + + var url = CreateUrl(urlPart); + + var httpClient = CreateHttpClient(_configuration.UserName, _configuration.Password, HttpContentTypes.TextPlain); + var response = httpClient.Get(url); + if (IsHttpError(response)) + { + throw new HttpException(response.StatusCode, string.Format("Error {0}: Thrown with URL {1}", response.StatusDescription, url)); + } + + return response.RawText; + } + private bool CheckForUserNameAndPassword() { return !_configuration.ActAsGuest && string.IsNullOrEmpty(_configuration.UserName) && string.IsNullOrEmpty(_configuration.Password);