Public Sub TestURL
Dim Link As String = "My URL....."
Dim GetParameters() As String = Array As String ("Key1", "Value1", "Key2", "Value2")
Dim Token As String = "" 'token JWT
Wait For (GetURL(Link, GetParameters, Token)) Complete (DataResult As String)
Log(DataResult)
Dim Data As Map = CreateMap("User" : "xxxx", "Password" : "xxxxx")
Dim PostParameters As String = Data.As(JSON).ToString
Dim Token As String = "" 'token JWT
Wait For (PostURL(Link, PostParameters, Token)) Complete (DataResult As String)
Log(DataResult)
End Sub
Public Sub PostURL(URL As String, Parameters As String, Token As String) As ResumableSub
Dim Result As String
Dim j As HttpJob
Try
j.Initialize("", Me)
j.PostString (URL, Parameters)
j.GetRequest.SetHeader("Content-Type","application/json")
If Not(Token.Length = 0) Then j.GetRequest.SetHeader("Authorization", $"Bearer ${Token}"$)
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
Public Sub GetURL(URL As String, Parameters() As String, Token As String) As ResumableSub
Dim Result As String
Dim j As HttpJob
Try
j.Initialize("", Me)
j.Download2(URL, Parameters)
j.GetRequest.SetHeader("Content-Type","application/json")
If Not(Token.Length = 0) Then j.GetRequest.SetHeader("Authorization", $"Bearer ${Token}"$)
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