Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Requesting an image from a site that requires user and password

    I need to download an image from an URL that requires authentication.

    URL = "http://192.168.10.32:8827/folder/image.png"

    I have tried using "MSXML2.ServerXMLHTTP" and "WinHttp.WinHttpRequest.5.1" but I receive the same error in both cases:

    "A connection with the server could not be established"

    I think it's an authentication problem.
    User and password are stored in variables. And they are correct.

    Dim objSrvHTTP: Set http = Server.CreateObject("MSXML2.ServerXMLHTTP")
    http.open "GET",url, False, user, pass
    http.setRequestHeader "Authorization", "Basic " & Base64Encode(user&":"&pass)
    http.send

    Or

    Set req = CreateObject( "WinHttp.WinHttpRequest.5.1" )
    req.Open "GET", url, False
    req.SetCredentials user, , HTTPREQUEST_SETCREDENTIALS_FOR_SERVER
    req.SetAutoLogonPolicy(0)
    req.Send


    Is there any other method to authenticate to a site before you proceed to download?

    Thanks.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,613
    Thanks
    80
    Thanked 4,634 Times in 4,596 Posts
    Are you talking about windows authentication? Or a site that uses a web page for logging in?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •