1

I'm trying to use the following code to download a webpage:

dim xmlhttp : set xmlhttp = createobject("MSXML2.ServerXMLHTTP")
dim fso : set fso = createobject ("scripting.filesystemobject")
dim newfile : set newfile = fso.createtextfile("getVersion.htm", true)

xmlhttp.SetOption SXH_OPTION_IGNORE_SERVER_SSL_CERT_ERROR_FLAGS, true
xmlhttp.open "GET", "https://mysite:8443/remote/epo.GetVersion", "username", "password"
xmlhttp.send

newfile.write (xmlhttp.responseText)
newfile.close

However, it fails with "mxm13.dll: The parameter is incorrect." on line 6. What am I doing wrong?

Pickle
  • 1,064
  • 9
  • 33
  • 51

2 Answers2

2

The 3rd argument to open should be a boolean, specifying whether or not the request should be asynchronous.

oServerXMLHTTPRequest.open bstrMethod, bstrUrl, bAsync, bstrUser, bstrPassword

bstrMethod
The HTTP method used to open the connection, such as PUT or PROPFIND. For ServerXMLHTTP, this parameter is case-sensitive and the method name must be entered in all upper-case letters.
bstrUrl
The requested URL. This can be either an absolute URL, such as "http://example.com/Mypath/Myfile.asp", or a relative URL, such as "../MyPath/MyFile.asp".
bAsync (optional)
Boolean. Indicator as to whether the call is asynchronous. The default is False (the call does not return immediately).
bstrUser (optional)
The name of the user for authentication.
bstrPassword (optional)
The password for authentication. This parameter is ignored if the user parameter is Null or missing.

With a bit of experimentation and help from another question, I think you just need to change

xmlhttp.SetOption SXH_OPTION_IGNORE_SERVER_SSL_CERT_ERROR_FLAGS, true

to

xmlhttp.SetOption 2, xmlhttp.GetOption(2) - SXH_OPTION_IGNORE_SERVER_SSL_CERT_ERROR_FLAGS
Community
  • 1
  • 1
0

If you're using Windows 8, Windows 8.1 or Windows Server 2012/2012R2, you might have to apply the following HotFix, which fixed this problem for me in a similar scenario:

https://support.microsoft.com/en-us/help/2968741/error-0x80070057-when-sql-server-communicates-to-a-web-server-using-st

For further info you can also read this post on my blog or take a look to this other SO thread.

Darkseal
  • 9,205
  • 8
  • 78
  • 111