I host a local server on my pc with Plumber from R.
Next I call the server from Excel VBA.
If I use Debug.Print getHTTP(myurl)
I do receive an up-to-date response.
If I use Debug.Print (http.responseText)
I do receive an outdated response. I assume from cache.
If I call myurl with browser Chrome the response is up-to-date.
Please see code below.
Any idea what can be the cause of the outdated response from Debug.Print (http.responseText)
?
Thanks a lot!
Public Function getHTTP(ByVal url As String) As String
With CreateObject("MSXML2.ServerXMLHTTP.6.0")
.Open "GET", url, False: .send
getHTTP = StrConv(.responseBody, vbUnicode)
End With
End Function
Sub APItest()
Dim myurl As String
Dim JSON As Object
Dim http As Object
myurl = "http://127.0.0.1:1234/my_local_api_server"
Debug.Print getHTTP(myurl) 'this line gives actual output
Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "GET", myurl, False
http.send
Debug.Print (http.responseText) 'this line gives outdated output from cache
End Sub