protected async Task <T> SendAsync <T>( HttpMethod method, string path, [AllowNull] Dictionary <string, string> queryParams = null, [AllowNull] Dictionary <string, string> formParams = null ) where T : class { this.logger?.LogSend(method, path, queryParams, formParams); string query = this.BuildQuery(queryParams); HttpContent content = this.BuildContent(formParams); foreach (string host in config.GetHosts()) { try { HttpRequestMessage request = new HttpRequestMessage(method, this.BuildUri(host, path, query)); if (content is { }) { request.Content = content; } this.logger?.LogRequest(request); HttpResponseMessage response = await httpClient.SendAsync(request); this.logger?.LogResponse(response); if (response.IsSuccessStatusCode) { T result = JsonConvert.DeserializeObject <T>(await response.Content.ReadAsStringAsync()); this.logger?.LogResult <T>(result); return(result); } }