Android Question OkHttpUtils2 not sending username password

mvpmedia

Member
Licensed User
Longtime User
I can run this get request in my browser to trigger outlets on a power conditioner:

but in the B4a log console I get an html login page instead of the expected response:
1667987664747.png


and expected response:
<?xml version="1.0"?>
<request>
<outlet_status>0,0,0,1,1,0,0,0,0,0,0,0</outlet_status>
<auto_reboot>0</auto_reboot>
</request>

This is what I tried so far:
B4a Code:
Sub Button_AllOff_Click
    Dim j As HttpJob
    j.Initialize("", Me)
    j.Username=""
    j.Password=""
    'j.Download("http://192.168.1.185/control.cgi?outlet=0&command=0")
    'j.Download2("http://192.168.1.185/control.cgi", Array As String ("outlet","0","command","0"))
    Wait For (j) jobdone (j As HttpJob)
    If j.Success Then
        Log(j.GetString)
    End If
End Sub
 

mvpmedia

Member
Licensed User
Longtime User
This worked:
getrequest.setheader:
    j.GetRequest.SetHeader("Authorization", "Basic *******")

and it still works when I remove username and password.
 
Upvote 0
Top