HTTPS POST请求使用VBA for Excel [英] HTTPS POST request using VBA for Excel

查看:1015
本文介绍了HTTPS POST请求使用VBA for Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用WinHttp.WinHttpRequest.5.1从Excel中的VBA发送HTTP POST请求。
但是当我收到SSL证书错误时,我无法设法为HTTPS执行此操作。

I use "WinHttp.WinHttpRequest.5.1" to send HTTP POST requests from VBA in Excel. But I could not manage to do it for HTTPS, as I received an SSL certificate error.

您将使用什么VBA代码来协商SSL连接一个来自VBA Excel的网站?

What VBA code would you use to negotiate an SSL connection to a website from VBA in Excel ?

推荐答案

WinHttpRequest 对象具有一个 SetClientCertificate 方法。请尝试从 MSDN (I)获取的代码示例尝试适应VBA):

The WinHttpRequest object has a SetClientCertificate method. Try this code example taken from the MSDN (I tried to adapt it for VBA):

' Instantiate a WinHttpRequest object. '
Dim HttpReq as new ActiveXObject("WinHttp.WinHttpRequest.5.1")

' Open an HTTP connection. '
HttpReq.Open("GET", "https://www.test.com/", false)

' Select a client certificate. '
HttpReq.SetClientCertificate("LOCAL_MACHINE\Personal\My Certificate")

' Send the HTTP Request. '
HttpReq.Send()

这篇关于HTTPS POST请求使用VBA for Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆