34345

mail@pastecode.io avatar
unknown
csharp
8 months ago
844 B
3
Indexable
Never
 var loginRequest = (HttpWebRequest)WebRequest.Create("https://v4.sonicbit.net/api/web/login");
        loginRequest.Method = "POST";

        var credentials = new NetworkCredential("", "");
        loginRequest.Credentials = credentials;

        try
        {
            using (var response = (HttpWebResponse)loginRequest.GetResponse())
            {
                Console.WriteLine("Успешная авторизация");
            }
        }
        catch (WebException ex)
        {
            if (ex.Response != null)
            {
                var response = (HttpWebResponse)ex.Response;
                if (response.StatusCode == HttpStatusCode.Unauthorized)
                {
                    Console.WriteLine("Ошибка авторизации");
                }
            }
        }
Leave a Comment