private async Task <T> SendRequest <T>(HttpRequestMessage request, JsonConverter[] converters = null) { var response = await httpClient.SendAsync(request).ConfigureAwait(false); { if (!response.IsSuccessStatusCode) { throw await ApiException.CreateSpecificExceptionAsync(response).ConfigureAwait(false); } var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false); return(typeof(T) == typeof(string) ? (T)(object)content : JsonConvert.DeserializeObject <T>(content, converters)); } }
private async Task <T> SendRequest <T>(HttpRequestMessage request) { if (!ownHttpClient) { request.Headers.Add("Auth0-Client", agentString); } using (var response = await httpClient.SendAsync(request).ConfigureAwait(false)) { if (!response.IsSuccessStatusCode) { throw await ApiException.CreateSpecificExceptionAsync(response).ConfigureAwait(false); } var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false); return(typeof(T) == typeof(string) ? (T)(object)content : JsonConvert.DeserializeObject <T>(content)); } }