I have a problem sending POST request with VB6. The code below works properly on Windows7 but on Windows XP it run without any runtime error and it sends the packet but looks like it doesn't append the post data in the packet. My code is like this:
Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "POST", url, False
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.setRequestHeader "Content-Length", Len(parameters)
xmlhttp.Send parameters
where paramaters contains the string "bar=foo&foo=bar"
I already tried to add the references to Microsoft XML, v4.0.
I found a solution. I changed the code in this way:
Dim xmlhttp As WinHttp.WinHttpRequest
...
Set xmlhttp = New WinHttp.WinHttpRequest
xmlhttp.open "POST", url, False
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.setRequestHeader "Content-Length", Len(parameters)
xmlhttp.Send parameters
Adding the reference to "Microsoft WinHTTP Services, version 5.1"
And now it works.