将CMD cURL转换为Excel VBA代码以便在HTTPS站点中获取JSON数据?

我需要从这个URL“ https://localhost/appserver/portal/api/1.0/apps ”得到一个JSON,我可以使用CMD cURL来做到这一点。

curl 'https://<host>/appserver/portal/api/1.0/apps' -H 'Accept-Encoding: gzip, deflate, sdch, br' -H 'Accept-Language: en-US,en;q=0.8' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Referer: https://<host>/appserver/portal/login;jsessionid=A7DE3EB54B8E5151DA304D90DB48DF2E' -H 'Cookie: JSESSIONID=952E2B1F8E714BE302CA902469DB0781' -H 'Connection: keep-alive' -H 'Cache-Control: max-age=0' --compressed --insecure 

我正在尝试使用Excel VBA获取JSON。 在HTTPS站点中使用VBA获取JSON数据的正确方法是什么?

尝试这样的事情:

 With CreateObject("MSXML2.ServerXMLHTTP") .Open "GET", "https://<host>/appserver/portal/api/1.0/apps", False .SetRequestHeader "Accept", "application/json, text/javascript, */*; q=0.01" .SetRequestHeader "Accept-Encoding", "gzip, deflate, sdch, br" .SetRequestHeader "Accept-Language", "en-US,en;q=0.8" .SetRequestHeader "Upgrade-Insecure-Requests", "1" .SetRequestHeader "User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36" .SetRequestHeader "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" .SetRequestHeader "Referer", "https://<host>/appserver/portal/login;jsessionid=A7DE3EB54B8E5151DA304D90DB48DF2E" .SetRequestHeader "Cookie", "JSESSIONID=952E2B1F8E714BE302CA902469DB0781" .SetRequestHeader "Connection", "keep-alive" .SetRequestHeader "Cache-Control", "max-age=0" .Send sHeaders = .getAllResponseHeaders sContent = .responseText End With 

您可以尝试MSXML2.ServerXMLHTTPMSXML2.XMLHTTP与特定的网站。 请注意, MSXML2.XMLHTTP将发送保存的cookie,无论您是否添加cookie标头。