I am new to VBA so this is probably my problem. I am trying to perform a HTTP POST from Excel to a web service, and I can POST quite happily, until I change the code so that I am posting content in my message, at which point I get the following error:
Run-time error '-2147024809 (80070057)':
The Parameter is incorrect.
My code is as follows:
Dim oHttp As Object
Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")
Call oHttp.Open("POST", url, False)
oHttp.setRequestHeader "Content-Type", "application/text"
oHttp.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
Call oHttp.send(content)
httpPOST = oHttp.responseText
The line which is killing the code is the oHttp.send - if I do not pass any content then it is fine, as soon as I put content here it is unhappy.
The content parameter is a large string containing comma separated text and includes line feeds. I think this is why it is unhappy, if I change the string to simply a short "Hello" then the send is sucessful and the application happily makes it to the next line, before hitting the run-time error:
The data necessary to complete this operation is not yet available
So I guess my question is, how do I POST a large block of text to a server?
Thanks
Thanks for the comments, I managed to get it to work by converting the string to a binary array and then send the binary array over.