string response; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls|SecurityProtocolType.Ssl3; ServicePointManager.ServerCertificateValidationCallback = delegate(object obj, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) { return true; }; WebClient client = new WebClient(); string credentials; credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes("gujarat_ws_client" + ":" + "guj@r@t_C|ient")); client.Headers.Add("Authorization", "Basic Z3VqYXJhdF93c19jbGllbnQ6Z3VqQHJAdF9DfGllbnQ="); try { var strEaushadhiURI = "https://xxx.com/"; System.Net.ServicePointManager.ServerCertificateValidationCallback = (object se, System.Security.Cryptography.X509Certificates.X509Certificate cert, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslerror) => true; response = client.DownloadString(new Uri(strEaushadhiURI + "/AMH/" + txtVoucherNumber.Text.Trim())); System.Net.ServicePointManager.ServerCertificateValidationCallback = null; TextBox1.Text = response; } catch (Exception ex) { TextBox1.Text = ex.Message; }
The remote server returned an error: (401) Unauthorized.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)