Linga
Linga

Reputation: 10573

VBA HTTP POST not working

I am trying to send HTTP post through VBA. Here is my part of code

Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
objHTTP.Open "POST", url, False
objHTTP.setRequestHeader "User-Agent", "EPS 1.0"
objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objHTTP.setRequestHeader "content", postString
objHTTP.setRequestHeader "Content-Length", Len(postString)
objHTTP.send

The problem is, the code is working only if the postString is less than 65535 characters. If it exceeds 65535 characters, it throws error on below line:

ERROR: Incorrect parameter

objHTTP.setRequestHeader "content", postString

Any ideas about this? Do I need to set any other parameter to make it work around?

Upvotes: 12

Views: 1781

Answers (1)

Tim Williams
Tim Williams

Reputation: 166755

Per: https://support.microsoft.com/en-us/kb/290591

This should work:

postString = "id=" & String(66000,"x")
Dim xmlhttp 
Set xmlhttp = Createobject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST", url, false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.send postString

If it does not work, then maybe there's something going on with your server-side setup.

Upvotes: 3

Related Questions