The remote server returned an error: (401) Unauthorized (Snom D375)

532 views Asked by At

I try to control my snom phone (D375) remotely with a C# Programm. This is the code for the remote dialing:

     string httpCallCommand = string.Format(
        HTTP_SNOM_CALL_COMMAND,
        Credentials.Instance.PhoneUri.ToString(),
        CALL_COMMAND,
        number,
        MY_NUMBER);

     HttpWebRequest request = (HttpWebRequest)WebRequest.Create(httpCallCommand);
     request.Credentials = new NetworkCredential(Credentials.Instance.User, Credentials.Instance.Password);

     try
     {
        request.GetResponse();
     }
     catch (Exception e)
     {
        if (((WebException)e).Status == WebExceptionStatus.ConnectionClosed)
        {
           // Do nothing because it's normal for the Snom telephone to not answer on this request.
        }
        else if (e.Message.Contains("401"))
        {
           MessageHelper.MessageBoxService.ShowOnTop(
              MessageType.Error,
              MessageHelper.WrongSettingsMessage(true, true, true, ConnectionType.WRONG_CREDENTIALS));
           ClassLogger.Info(LogMessages.WrongCredentials, e.ToString());
        }
        else
        {
           MessageHelper.MessageBoxService.ShowOnTop(
              MessageType.Error,
              MessageHelper.WrongSettingsMessage(true, true, true, ConnectionType.NO_CONNECTION));
           ClassLogger.Info(LogMessages.NoConnection, e.ToString());
        }
     }

The call goes through, but I also get "The remote server returned an error: (401) Unauthorized" from the request.GetResponse();. The authentication scheme on the phone is set to Basic. I can't figure out why I get the exception. Here are some syntax information if needed http://wiki.snom.com/FAQ/Can_I_control_my_snom_phone_remotely

0

There are 0 answers