Android Question vb to b4a

vmag

Active Member
What am I doing wrong?
I'm translating the code from VB
ASP.net:
Dim myUrl As String
Dim answer As String
myUrl = "https://...."
Dim WinHttpReq As Object
Set WinHttpReq = CreateObject("MSXML2.XMLHTTP")
WinHttpReq.Open "GET", myUrl, False
WinHttpReq.setRequestHeader "Content-Type:", "application/json"
WinHttpReq.setRequestHeader "X-API-KEY:", "abcdef........"
WinHttpReq.send
answer = WinHttpReq.responseText
to B4A
B4X:
Dim http As HttpJob
    Dim url As String
    url = "https://..."
    http.Initialize("",Me)
    http.PostString(url,"")
    http.GetRequest.SetHeader("Content-Type:", "application/json")
    http.GetRequest.SetHeader("X-API-KEY:", "abcdef........"")
    txtAnsv.text=http.GetString
there are no errors, but the application does not work
 

vmag

Active Member
What am I doing wrong?
I'm translating the code from VB
ASP.net:
Dim myUrl As String
Dim answer As String
myUrl = "https://...."
Dim WinHttpReq As Object
Set WinHttpReq = CreateObject("MSXML2.XMLHTTP")
WinHttpReq.Open "GET", myUrl, False
WinHttpReq.setRequestHeader "Content-Type:", "application/json"
WinHttpReq.setRequestHeader "X-API-KEY:", "abcdef........"
WinHttpReq.send
answer = WinHttpReq.responseText
to B4A
B4X:
Dim http As HttpJob
    Dim url As String
    url = "https://..."
    http.Initialize("",Me)
    http.PostString(url,"")
    http.GetRequest.SetHeader("Content-Type:", "application/json")
    http.GetRequest.SetHeader("X-API-KEY:", "abcdef........"")
    txtAnsv.text=http.GetString
there are no errors, but the application does not work

It's decided:
B4X:
Dim j As HttpJob
    Dim url As String
    url = "https://....."
    j.Initialize("",Me)
    j.Download(url)
    j.GetRequest.SetHeader("Content-Type","application/json")
    j.GetRequest.SetHeader("X-API-KEY", "abcd.....")
    wait for (j) jobdone(j As HttpJob)
    If j.Success Then
        txtAnsv.text=j.GetString
        Else
            xui.MsgboxAsync("Error","!")
    End If
    j.Release
 
Upvote 0
Top