Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
curl -X GET "https://api.example.com/submit"
Public Sub GETHttpRequest As String
Dim Result As String
Dim j As HttpJob
Try
j.Initialize("", Me)
j.Download2("https://api.example.com/submit", Null)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Result = j.GetString
End If
Catch
Log(LastException)
End Try
j.Release
Return Result
End Sub
-------------------
curl -X GET "https://api.example.com/submit" -d '{"key1":"value1"}' -H "Content-Type: application/json"
Public Sub GETHttpRequest As String
Dim Result As String
Dim j As HttpJob
Try
j.Initialize("", Me)
j.Download2("https://api.example.com/submit", {"key1":"value1"})
j.GetRequest.SetHeader("Content-Type","application/json"
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Result = j.GetString
End If
Catch
Log(LastException)
End Try
j.Release
Return Result
End Sub
-------------------
curl -X POST "https://api.example.com/submit" -d '{"key1":"value1"}' -H "Content-Type: application/json"
Public Sub POSTHttpRequest As String
Dim Result As String
Dim j As HttpJob
Try
j.Initialize("", Me)
j.PostString("https://api.example.com/submit",{"key1":"value1"})
j.GetRequest.SetHeader("Content-Type","application/json"
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Result = j.GetString
End If
Catch
Log(LastException)
End Try
j.Release
Return Result
End Sub
-------------------
curl -X PUT "https://api.example.com/submit" -d '{"key1":"value1"}' -H "Content-Type: application/json"
Public Sub PUTHttpRequest As String
Dim Result As String
Dim j As HttpJob
Try
j.Initialize("", Me)
j.PutString("https://api.example.com/submit",{"key1":"value1"})
j.GetRequest.SetHeader("Content-Type","application/json"
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Result = j.GetString
End If
Catch
Log(LastException)
End Try
j.Release
Return Result
End Sub