An example is in the attached file. You need to run macro Test
. Below is the text of the macro and the header of main function.
Option Explicit
Option Compatible
Sub Test
Dim url As String, retval As String, result As String
url="https://ndcdyn.interactivebrokers.com/Universal/servlet/FlexStatementService.SendRequest?t=280014687756071353099584&q=583344&v=3"
retval=CurlCall(url)
If Left(retval, 1)<>"*" Then ' Not error
result=fileToStr(retval)
Msgbox result
End If
End Sub
' lang:en
' Call the Curl utility.
' - arg: utility argument (options).
' - postData: sets the data (body) for the POST request. If the first character is "@", then it is interpreted as a file name.
' - out: redirect stdout output for curl. The file name or only the extension can be specified (will be redirected
' to a temporary file with this extension). If you do not need to redirect, then specify an empty string or "-".
' If the out parameter is omitted, then redirect to a temporary file.
'
' Returns:
' On normal completion, the name of the file with redirected output stdout, or an empty string if no output was redirected.
' `*1`: Error calling curl: The file specified by the --stderr parameter was not created.
' `*2`: Error: The file specified by the postData parameter does not exist.
' `*filename`: the name of the file containing the error log with a "*" at the beginning (in URL format).
Function CurlCall(Byval arg, Optional postData as String, Optional Byval out) as String
CurlCall.ods (13.0 KB)