Microsoft.XMLHTTP request works in Excel VBA but not in Visual Studio Code

150 views Asked by At

The following code works fine in an Excel VBA module

Sub test()

    Dim restReq, url, apiKey
    url = "https://some.server.com/?param1=123"
    apiKey = "123342545"
    Set restReq = CreateObject("Microsoft.XMLHTTP")
    
    restReq.Open "GET", url, False
    restReq.SetRequestHeader "accept", "application/json"
    restReq.SetRequestHeader "X-ApiKey", apiKey
    restReq.send ("")
    
    'MsgBox restReq.getAllResponseHeaders
    MsgBox restReq.responseText

End Sub

But when I run the exactly same code from Visual Studio Code, I get this non helpful error message:

MSXML3.DLL A security problem occurred.

Any ideas, where the difference could be?

0

There are 0 answers