public async Task <T> PostAsAsync <T>(string Method, object Body, bool IsAnonymous = false) { string path = string.Format("{0}{1}", ConfigurationManager.AppSettings["NotifEyeIntegratedAPIEndpoint"], Method); var httpClient = new HttpClient(); if (!IsAnonymous) { httpClient.DefaultRequestHeaders.Add("authenticatedtoken", _httpContextProvider.GetIntegratedNotifyToken()); } var response = await httpClient.PostAsync(path, new StringContent(JsonConvert.SerializeObject(Body), Encoding.UTF8, "application/json")); if (response.IsSuccessStatusCode) { try { return(await response.Content.ReadAsAsync <T>()); } catch (Exception) { throw new Exception(await response.Content.ReadAsStringAsync()); } } else { throw PrepareHttpException(response, Method, await response.Content.ReadAsStringAsync()); } }