'XmlHttp Post in Excel VBA - The download of this specified resource has failed
To help others who find this I am trying to send a HTTPS POST message to URL. Using my first bit of code I was getting this error: No Credentials were available in the client certificate
I eventually solved that issue by using
oHttp = CreateObject("MSXML2.XMLHTTP.6.0")
instead of
oHttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
However all this did was change the error message to The download of this specified resource has failed
I found by accident that if I change the POST to a GET in the code below it will not get this error. And after sending 1 GET request the POST requests no longer failed (as long as I kept excel open). Any idea why a GET request would be required before POST requests can be sent? Sending the same through Postman did not require a GET first.
Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0") 'the good one
oHttp.Open "POST", myURL, False 'change this to GET once to get code to work.
oHttp.setRequestHeader "Content-Type", "application/json"
oHttp.setRequestHeader "Accept-Encoding", "gzip, deflate, br"
oHttp.send body
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
