Android Question NeworkCredential Error

Discussion in 'Android Questions' started by M Zuhri, Aug 12, 2019.

  1. M Zuhri

    M Zuhri Member Licensed User

    Hi all,
    Can anyone help me, in http job, how to use NetworkCredential. I have use this technique in vb.net and now i need to connect through b4a.

    'VB.NET CODE
    Dim request As WebRequest = WebRequest.Create(Uri.Trim)
    request.Credentials = New NetworkCredential(Username, Password)

    .B4A CODE
    j.Download("http://localhost/api//getdetails")
    j.Username = "Administrator"
    j.Password = "456

    B4A code gives me error,
    "ResponseError. Reason: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:57869, Response:"
    java.lang.Object@307c6d2
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    localhost is wrong. localhost = current device or current emulator.
     
    M Zuhri likes this.
  3. M Zuhri

    M Zuhri Member Licensed User

    Yes Erel, after i change it to ip address only it start working... Thanks
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice