Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- var uri = new Uri("https://46.13.13.108:11001");
- var credentialsCache = new CredentialCache { { uri, "NTLM", new NetworkCredential("konica", "Kotatko123+", "ntcogebi") } };
- var handler = new HttpClientHandler { Credentials = credentialsCache };
- handler.ServerCertificateCustomValidationCallback += Program.CertificateValidationCallBack;
- var httpClient = new HttpClient(handler) { BaseAddress = uri, Timeout = new TimeSpan(0, 0, 10) };
- httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
- var response = httpClient.GetAsync("api/vendors?id=31045687&vatnum=CZ43774750").Result;
- if (response.IsSuccessStatusCode)
- {
- Task<string> content = response.Content.ReadAsStringAsync();
- Console.WriteLine(content.Result);
- }
- else
- {
- throw new HttpRequestException(response.Content.ReadAsStringAsync().Result);
- }
- Console.ReadLine();
- }
- public static bool CertificateValidationCallBack(
- object sender,
- System.Security.Cryptography.X509Certificates.X509Certificate certificate,
- System.Security.Cryptography.X509Certificates.X509Chain chain,
- System.Net.Security.SslPolicyErrors sslPolicyErrors)
- {
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement