private async Task <HttpResponseMessage> RunAsync(string URI, HttpMethod verbe, HttpContent content) { // string pwdHash = sha256.getHashSha256(Pwd); string pwdHash = Pwd.sha256(); var credentials = new NetworkCredential(User, pwdHash); using (HttpClientHandler handler = new HttpClientHandler { PreAuthenticate = true, Credentials = credentials }) using (HttpClient clientREST = new HttpClient(handler) { MaxResponseContentBufferSize = 1000000 }) { clientREST.BaseAddress = new Uri(this.BaseURI); clientREST.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var byteArray = Encoding.ASCII.GetBytes(User + ":" + pwdHash); HttpRequestMessage request = new HttpRequestMessage(verbe, URI); request.Headers.CacheControl = new CacheControlHeaderValue() { NoCache = true }; clientREST.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray)); if (content != null) { request.Content = content; } var stp = request.ToString(); HttpResponseMessage response = clientREST.SendAsync(request).Result; //retourne le contenu de la réponse, si il s'agit d'une erreur, elle doit être traîtée return(response); } }