B4J Question Making a synchronous Http Call with jOkHttpUtils2

coldflame

Member
Hello Everyone,
I am trying to make a call to paystack to initiate a payment flow from my B4J WebServer, The issue I am having is that the webserver sends the api response before the response from paystack arrives. I am thinking of making the call synchronous by removing the Wait For, However job.GetString returns null and raises a java.io.FileNotFoundException exception. Please Help
B4X:
Public Sub InitializePayment(emailAddress As String, amount As String) As ResumableSub
    
    Dim requestBody As Map = CreateMap("email": emailAddress, "amount": amount)
    
    Dim job As HttpJob
    
    job.Initialize("", Me)
    
    job.PostString("https://api.paystack.co/transaction/initialize", requestBody.As(String))
    job.GetRequest.SetHeader("Authorization", $"Bearer ${SecretKey}"$)
    job.GetRequest.SetHeader("Content-Type", "application/json")
    
    Wait For (job) JobDone(job As HttpJob)
        
    If job.Success Then 
        Log(job.GetString)
    End If
    
    job.Release
    
    'Return a Map of the authorization url and reference code
    Return CreateMap()
End Sub
 
Top