Public Sub TestGetSarApiURL
'---- GET method types ---
Dim BaseUrl As String = "https://my api web"
'Option 1: without parameters
Wait For (GetSarApiURL1(BaseUrl)) Complete (Result As String)
Log(Result)
'Option 2: with Parameters
Dim Parameters() As String = Array As String ("Parameter1", "Value 1", "Parameter2", "value 2")
Wait For (GetSarApiURL2(BaseUrl, Parameters)) Complete (Result As String)
Log(Result)
End Sub
Public Sub GetSarApiURL1(URL As String ) As ResumableSub
Dim ResultURL As String
Dim j As HttpJob
Try
j.Initialize("", Me)
j.Download(URL)
j.GetRequest.SetHeader("Content-Type","application/json") 'Opcional: if return JSON
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
ResultURL = j.GetString
Else
Log(j.ErrorMessage)
End If
Catch
Log(LastException)
End Try
j.Release
Return ResultURL
End Sub
Public Sub GetSarApiURL2(URL As String, Parameters() As String) As ResumableSub
Dim ResultURL As String
Dim j As HttpJob
Try
j.Initialize("", Me)
j.Download2(URL, Parameters)
j.GetRequest.SetHeader("Content-Type","application/json") 'Opcional: if return JSON
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
ResultURL = j.GetString
Else
Log(j.ErrorMessage)
End If
Catch
Log(LastException)
End Try
j.Release
Return ResultURL
End Sub