Do I need something specia to make HTTP requests in a server handler ? I'm getting an error code ResponseError. Reason: Unauthorized, Response: when in server while this code works very well in a B4XPage Application.
Resumable subs can only work when there is a message queue. By default, server handlers end when the Handle sub is completed. They do not create a message loop. If you want to wait for an event then you need to call StartMessageLoop and later StopMessageLoop. Example of handler that downloads...
I’m not using any build configuration in any of the apps. I will zip the working project and send it to you because it contains my credentials. Then you’ll see yourself.
I see the issue you describe. It looks like the first request fails for some reason.
Implement a retry mechanism:
B4X:
Dim Success As Boolean = False
For retries = 1 To 5
Dim j As HttpJob
j.Initialize("",Me)
'''
wait for (j) JobDone(job As HttpJob)
Success = Job.Success
j.Release
If Success Then
Exit
Else
Sleep(500)
End If
Next
Log("RequestToPay: " & Success)
Return Success