Problem w/ WinHTTPRequest POST request and 64-bit Windows

poolhall

Active Member
Joined
Jan 9, 2009
Messages
350
Here's the description of my problem:

I'm using a couple of VBA routines in the same Excel file in different Windows versions but getting different results, which depends it is a 64 or 32-bit Windows version.

In the VBA project I have the following references:
*** Microsoft WinHTTP Services, version 5.1 (C:\WINDOWS\system32\WINHTTP.dll),
*** Microsoft XML, v6.0 (C:\WINDOWS\system32\msxml6.dll),
*** and other standard references.

What I am ultimately trying to do is to log into a secured website (via HTTPS), send POST request with login/password info into a webform, record session ID into a variable (Login routine) and pass this variable to the next routine, which sends POST request to fill data in another webform to send a query (SubmitQuery routine).

I can use WinHTTPRequest object or MSXML2.XMLHTTP60 object to send those POST request. Both works fine in the Login routine as long as I am using Windows XP (32-bit), regardless of Excel version (tried 2002 and 2007). However, in 64-bit Windows versions (tested in Vista and Win 7), WinHTTPRequest doesn't work for me. It seems it incorrectly sends the POST body message.

So for the Login routime I use MSXML2.XMLHTTP60 object to POST data, and it's fine with me.

But in the SubmitQuery I need to POST to the server the session ID from a cookie, and this is the reason I cannot use XMLHTTP60 object here, because it doesn't support cookies. So I use WinHTTPRequest in this routine, which for me only works with 32-bit Windows versions.

I hope this description is not too confusing.

Is there anything I can do in this situation? I tried to add a reference to winhttp.dll, which is located in %SystemRoot%\SysWOW64 folder, to see if it makes difference, but this reference doesn't seem to appear in the references list in my VBA Project.

Any help would be greatly appreciated. Please let me know if you need to see the actual code.
 
Last edited:

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Additional information.

Since the last post in this thread, I have written a VBA program that logs into another secure website, and retrieves some data using WinHTTPRequest. The program works fine on both 32 and 64 bit Windows version.

The only difference between the two programs is the form content type used to POST data to a web server by WinHTTPRequest.

Application/x-www-form-urlencoded type works just fine with 64-bit Windows.

Multipart/form-data type does not.

If anybody ever encountered this kind of problem, please let me know. Thanks a lot.
 
Upvote 0
Finally found the answer: the problem solves by using MSXML2.ServerXMLHTTP60 instead of WinHTTPRequest. Simple as that.
 
Upvote 0

Forum statistics

Threads
1,214,589
Messages
6,120,415
Members
448,960
Latest member
AKSMITH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top