Code:
Sub test()
Dim myHTTP As MSXML2.xmlhttp
Dim myDom As MSXML2.DOMDocument
Dim orderno, errormsg, lineerr, lineerrmsg As MSXML2.IXMLDOMNode
Dim myxml As String
boundary = "-----------------------------29772313742745"
myxml = "--" & boundary & vbCrLf & _
"<?xml version=""1.0"" encoding=""UTF-8""?>" & _
"<OnlineCheck>" & _
"<Header>" & _
"<BuyerAccountId></BuyerAccountId>" & _
"<AuthCode></AuthCode>" & _
"<Type>Full</Type>" & _
"</Header>" & _
"<Item line=""1"">" & _
"<ManufacturerItemIdentifier/>" & _
"<DistributorItemIdentifier>1088963</DistributorItemIdentifier>" & _
"<Quantity>1</Quantity>" & _
"</Item>" & _
"</OnlineCheck>" & vbCrLf & vbCrLf & boundary & "--"
Set myHTTP = CreateObject("msxml2.xmlhttp")
Set myDom = CreateObject("MSXML2.DOMDocument")
myDom.async = False
myDom.Load (myxml)
myHTTP.Open "POST", "", False
myHTTP.setRequestHeader "Content-Type", "multipart/form-data; boundary=" & boundary
myHTTP.setRequestHeader "Content-Disposition", "form-data; name=""xmlmsg"""
myHTTP.setRequestHeader "Content-Length", Len(myxml)
myHTTP.send (myDom.xml)
MsgBox myHTTP.responseText
End Sub
M'kay.
I have to send the xml (myxml) to a website via POST.
It has to be multipart/form-data, and has to have a name of 'xmlmsg'.
Don't ask me why, it's the way they've set it up.
I have the exact same code working for another of our suppliers; with the one difference being the setRequestHeade r lines. None of our other suppliers require these; which leads me to think that's the problem.
When I ommit all the headers, I get a message saying basically 'wrong format, form name must be xmlmsg'. When I add the content-type header, this changes to <error>-3</error>.
I know, helpful right?
The company doesn't know what the error means, and haven't got an error code list. I don't know what's happened to whoever set the system up for them.
We use Access2003 and I'd prefer not to have to make a webpage to do this.
Thanks for any help/guidance you can give =)
Mandi
Comment