public static async Task <HttpResponse> Post(string url, HttpContent content, TokenModel token = null) { using (var client = new HttpClient()) { if (token != null) { client.DefaultRequestHeaders.Authorization = token.GetHeader(); } var response = await client.PostAsync(url, content); var responseCode = response.StatusCode; var responseContent = response.Content; var mediaType = response.Content?.Headers?.ContentType?.MediaType; return(mediaType == "application/json" ? new HttpResponse(responseCode, await responseContent.ReadAsStringAsync(), mediaType) : new HttpResponse(responseCode, await responseContent.ReadAsByteArrayAsync(), mediaType)); } }