using System.Net; namespace DahuaIPCRename { internal class Program { public static Dictionary listIPC = new Dictionary { {"172.22.10.122","Этаж 2|Пом. 247"}, {"172.22.10.123","Этаж 2|Пом. 248-4"}, {"172.22.10.124","Этаж 2|Пом. 248-5"}, {"172.22.10.125","Этаж 2|Пом. 248-2"}, {"172.22.10.126","Этаж 2|Пом. 248-6"}, {"172.22.10.127","Этаж 2|Пом. 248-3"}, {"172.22.10.128","Этаж 2|Пом. 273-1"}, {"172.22.10.129","Этаж 2|Пом. 268-1"}, {"172.22.10.130","Этаж 2|Пом. 273-2"} }; static async Task Main(string[] args) { foreach (var ipc in listIPC) { string baseUrl = $"http://{ipc.Key}"; var credCache = new CredentialCache(); credCache.Add(new Uri(baseUrl), "Digest", new NetworkCredential("admin", "4NUDZhJ7")); using (var handler = new HttpClientHandler { Credentials = credCache, ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true }) using (var httpClient = new HttpClient(handler)) { string requestUrl = $"{baseUrl}/cgi-bin/configManager.cgi?action=setConfig&ChannelTitle[0].Name={ipc.Value}"; var response = await httpClient.GetAsync(requestUrl); try { response.EnsureSuccessStatusCode(); Console.WriteLine($"{ipc.Key}\tOK\t{ipc.Value}"); } catch (Exception) { Console.WriteLine($"{ipc.Key}\tNO\t{ipc.Value}"); return; } } } Console.ReadKey(); } } }