I'm having problems with HttpJob.
I'm not sure if the code is correct, but the code below sometimes seems to loop, and the application hangs.
Note that the post is inside a timer. I do not know if this could be a problem.
I'm not sure if the code is correct, but the code below sometimes seems to loop, and the application hangs.
Note that the post is inside a timer. I do not know if this could be a problem.
B4X:
Sub Timer1_tick
If txtToken.Text = "" Then Return
Timer1.Enabled = False
Dim j As HttpJob
j.Initialize("j", Me)
j.PostString("https://pos.globalfoodsoft.com/pos/order/pop", "")
j.GetRequest.SetHeader("Authorization", decrypt(txtToken.Text))
j.GetRequest.SetHeader("Accept", "application/json")
j.GetRequest.SetHeader("Glf-Api-Version", "2")
j.GetRequest.SetContentType("application/json")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Log("success")
Write(j.GetString) ' do stuffs
Else
Log("error: " & j.ErrorMessage)
End If
j.Release
Timer1.Enabled = True
End Sub
Sub JobDone(job As HttpJob)
Log(job.Tag)
If job.Success Then
Log(job.JobName & " - " & job.GetString)
End If
End Sub