public static string Get(this RestApiClient networkClient, string url) { var httpRequest = networkClient.CreateRequest(HttpMethod.Get, url); var httpClient = networkClient.HttpClient; var response = httpClient.SendAsync(httpRequest).Result; var responseContent = response.Content.ReadAsStringAsync().Result; if (response.IsSuccessStatusCode) { return(responseContent); } else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized) { if (networkClient.ShallRefreshToken()) { if (networkClient.InitiateTokenRefresh()) { return(Get(networkClient, url)); } } } throw new Exception(extractMessageFromErrorResponse(responseContent)); }
public static string Get(this RestApiClient networkClient, string url) { var httpRequest = networkClient.CreateRequest(HttpMethod.Get, url); var httpClient = networkClient.HttpClient; var response = httpClient.SendAsync(httpRequest).Result; var responseContent = response.Content.ReadAsStringAsync().Result; if (response.IsSuccessStatusCode) { return(responseContent); } throw new Exception(extractMessageFromErrorResponse(responseContent)); }