/// <summary> /// Performs HTTP requests (POST/GET) and returns the response. /// </summary> /// <param name="method" type="String">The HTTP method, post, get</param> /// <param name="endpoint" type="String">The API endpoint</param> /// <param name="content" type="HttpContent">The request body content</param> private HttpResponseMessage Proxy(string method, string endpoint, StringContent content = null) { using (HttpClient client = new HttpClient()) { string token = _dataStorageService.GetAccessToken(); HttpResponseMessage response; // Set constituent endpoint. client.BaseAddress = _apiBaseUri; // Set request headers. client.DefaultRequestHeaders.Add("bb-api-subscription-key", _appSettings.Value.SkyApiSubscriptionKey); client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", "Bearer " + token); // Make the request to constituent API. switch (method.ToLower()) { default: case "get": response = client.GetAsync(endpoint).Result; break; case "post": response = client.PostAsync(endpoint, content).Result; break; } return(response); } }