public T ExecuteGetRequest <T>(string subUrl) { var url = Uri.EscapeUriString(Endpoint + subUrl); var strResult = HttpClient.GetStringAsync(url).GetAwaiter().GetResult(); var result = Serialization.FromJson <ServicesResponse <T> >(strResult); if (!string.IsNullOrEmpty(result.Error)) { logger.Error("Service request error by proxy: " + result.Error); throw new Exception(result.Error); } return(result.Data); }
public T ExecutePostRequest <T>(string subUrl, string jsonContent) { var url = Uri.EscapeUriString(Endpoint + subUrl); var content = new StringContent(jsonContent, Encoding.UTF8, "application/json"); var response = HttpClient.PostAsync(url, content).GetAwaiter().GetResult(); var strResult = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); var result = Serialization.FromJson <ServicesResponse <T> >(strResult); if (!string.IsNullOrEmpty(result.Error)) { logger.Error("Service request error by proxy: " + result.Error); throw new Exception(result.Error); } return(result.Data); }