I am trying to call the rest API from Excel on another machine using VBA (yes, I know!) and MS function calls. I can set the auth header, and get to the appropriate places (at least the ones that exist, it seems that …/history/period/ should not have a trailing / if there is no timestamp?!) but the responsetext to the (successful) http call is always “”. Any clues anyone?
I get the right stuff back if I call it using curl on the raspberry pi, and I am quite capable to sucking stuff from every other website I have tried using the MS VBA HTTP60 functions, but HA just doesn’t work for me.
the calling code is (simplified):
Sub XHR_Get_URL_Bearer_AUTHED()
Dim XHR As XMLHTTP60
If XHR Is Nothing Then Set XHR = New XMLHTTP60
XHR.Open “GET”, “http://192.168.1.21:8123/api/history/period”, True
XHR.setRequestHeader “Authorization”, "Bearer "
XHR.setRequestHeader “Content-Type”, “application/json”
XHR.send
Do While XHR.readyState <> 4
DoEvents
Loop
Debug.Print “Status:”, XHR.Status
Debug.Print “Readystate:”, XHR.readyState
Debug.Print “Response Headers”, XHR.getAllResponseHeaders
Debug.Print “Response Body”, XHR.responseBody
Debug.Print “response Text”, XHR.responseText
End Sub
and what comes back is:
Status: 200
Readystate: 4
Response Headers Content-Type: application/json
Date: Mon, 10 May 2021 10:48:38 GMT
Server: Python/3.8 aiohttp/3.7.4.post0
Response Body
response Text
it takes long enough to return that I suspect the data has actually been send (a couple of MB at least) but then it has vanished without trace.