Request


Using WinHttp.WinHttpRequest

This is built into Windows.
Reference - Microsoft WinHTTP Services v5.1
Supports proxy credentials

Sub Request() 
Dim xmlhttp As WinHttp.WinHttpRequest
Dim sResponse As String

   Set xmlhttp = CreateObject("WinHttp.WinHttpRequest.5.1")
   
   xmlhttp.Open "GET", "https://bettersolutions.com/RestService"

   xmlhttp.SetAutoLogonPolicy (WinHttp.AutoLogonPolicy_Always)
   xmlhttp.Send
   sResponse = xmlhttp.ResponseText
End Sub

Using MSXML2.ServerXMLHTTP

This uses a dedicated HTTP client stack

Dim http As Object 
   Set http = CreateObject("MSXML2.ServerXMLHTTP.6.0")

   http.Open "POST", "https://api.example.com/data", False
   http.setRequestHeader "Content-Type", "application/json"
   http.send "{""name"":""Russell""}"

   Debug.Print http.Status
   Debug.Print http.responseText

Using MSXML2.XMLHTTP

This is on its way out
Uses the browser HTTP stack (WinInet), which introduces quirks that can break JSON API calls.
You want the simplest possible GET request
You don't need advanced headers or authentication
Reference - Microsoft XML v6.0
Supports proxy and server credentials

Sub Request() 
Dim xmlhttp As MSXML2.XMLHTTP60
Dim sDownloadDate As String
Dim sResponse As String

   xmlhttp = CreateObject("MSXML2.XMLHTTP60)
   sDownloadDate = VBA.Format(VBA.Now, "yyyy-mm-dd")
   
   Call xmlhttp.Open("GET", modConstants.g_sURL_PREFIX & modConstants.g_sURL_SUFFIX_COMBINEDINFO & sDownloadDate, False)

   xmlhttp.send
   sResponse = xmlhttp.responseText
End Sub

© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext