Announcement

Collapse
No announcement yet.

How to call a URL with authentication?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to call a URL with authentication?

    Dear HomeSeer Experts,
    I would like to send with my HomeSeer Zee a simple HTTP command to another device. Goal is to turn a virtual device on / off on another box.
    If I use the web browser the successful commands are:
    http://192.168.1.13/api/callAction?deviceID=34&name=turnOn

    http://192.168.1.13/api/callAction?deviceID=34&name=turnOff

    The web browser will ask me for login (admin) and password (admin).
    How can I call the same URL with the admin:admin authentication from a HomeSeer script command?
    &hs.GetURL("192.168.1.13/api/callAction?deviceID=34&name=turnOff",TRUE,80) did not do anything.

    And &hs.GetURL("http://admin:admin@192.168.1.13/api/callAction?deviceID=34&name=turnOff",TRUE,80) did not work either.

    Any advice?
    Would be great if you could help.


    Best regards,
    Alex

    #2
    One way is to use a script and the webrequest object and add credentials to the request.
    ie (C# code snippet)
    WebRequest myReq = WebRequest.Create(url);
    CredentialCache mycache = new CredentialCache();
    mycache.Add(new Uri(url), "Basic", new NetworkCredential(username, password));
    myReq.Credentials = mycache;
    -Rupp
    sigpic

    Comment


      #3
      Thank you :-)

      Sorry for the question.
      I am not at all a expert.
      Can I just copy the lines in a .vb file for the Zee? ...

      Sub Main ()
      WebRequest myReq = WebRequest.Create(192.168.1.13);
      CredentialCache mycache = new CredentialCache();
      mycache.Add(new Uri(192.168.1.13), "Basic", new NetworkCredential(admin, admin));
      myReq.Credentials = mycache;
      End Sub

      Comment

      Working...
      X