By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
463,115 Members | 733 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 463,115 IT Pros & Developers. It's quick & easy.

Require help with myHTTP please =)

P: 90
Expand|Select|Wrap|Line Numbers
  1. Sub test()
  2. Dim myHTTP As MSXML2.xmlhttp                     
  3. Dim myDom As MSXML2.DOMDocument                  
  4. Dim orderno, errormsg, lineerr, lineerrmsg As MSXML2.IXMLDOMNode      
  5. Dim myxml As String
  7. boundary = "-----------------------------29772313742745"
  10. myxml = "--" & boundary & vbCrLf &  _
  11. "<?xml version=""1.0"" encoding=""UTF-8""?>" & _
  12. "<OnlineCheck>" & _
  13. "<Header>" & _
  14. "<BuyerAccountId></BuyerAccountId>" & _
  15. "<AuthCode></AuthCode>" & _
  16. "<Type>Full</Type>" & _
  17. "</Header>" & _
  18. "<Item line=""1"">" & _
  19. "<ManufacturerItemIdentifier/>" & _
  20. "<DistributorItemIdentifier>1088963</DistributorItemIdentifier>" & _
  21. "<Quantity>1</Quantity>" & _
  22. "</Item>" & _
  23. "</OnlineCheck>" & vbCrLf & vbCrLf & boundary & "--"
  25. Set myHTTP = CreateObject("msxml2.xmlhttp")
  26. Set myDom = CreateObject("MSXML2.DOMDocument")
  27. myDom.async = False
  28. myDom.Load (myxml)
  29. myHTTP.Open "POST", "", False
  30. myHTTP.setRequestHeader "Content-Type", "multipart/form-data; boundary=" & boundary
  31. myHTTP.setRequestHeader "Content-Disposition", "form-data; name=""xmlmsg"""
  32. myHTTP.setRequestHeader "Content-Length", Len(myxml)
  34. myHTTP.send (myDom.xml)
  36. MsgBox myHTTP.responseText
  38. End Sub
Can anyone spot anything obviously wrong with this code?

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 setRequestHeader 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 =)

Sep 19 '08 #1
Share this Question
Share on Google+
3 Replies

P: 90
I've tried the code without the boundarys in 'myxml'.
I've tried it with the headers declared in the posted data rather than using setRequestHeaders.
I've tried everything I can think of and I swear I'm just going backwards.

I think I just need to set the name to xmlmsg, but I can't figure out how.
I know in html it would be <form name="xmlmsg"> but in vba....

I've tried
Expand|Select|Wrap|Line Numbers
  1. SetRequestHeader="Content-Disposition", "form-data: name=""xmlmsg"""
  2. SetRequestHeader="Content-Disposition", "name=""xmlmsg"""
  3. SetRequestHeader="Content-Disposition", "name='xmlmsg'"
  4. SetRequestHeader="Content-Disposition", "name=xmlmsg"
  5. SetRequestHeader="ContentDisposition", "name=""xmlmsg"""
  6. SetRequestHeader="name", "xmlmsg"
(Not all at once though, obviously)

Nothing seems to work.

Does anyone know how to set that?

Sep 29 '08 #2

Expert Mod 2.5K+
P: 2,545
I suspect you are trying the wrong property here; I think CONTENT-TYPE would be more appropriate, since it is this standard header that can be used to specify that the content is a multi-part form. However, this is not my specialist area at all (or the Access forum's). Would you prefer your post to be moved to the HTML forum for a more considered view?

In the meantime you may wish to look up the following references to the standard headers and their meanings: (look up CONTENT-TYPE) (look up Multipart Types)

Sep 29 '08 #3

P: 90
I suspect you are trying the wrong property here; I think CONTENT-TYPE would be more appropriate,
Thanks for the reply.
I'm using content type too; and I know that one works as when I don't use it I get an error about using the wrong type. When I do use it, I just get -3.

Because I didn't get a reply in over a week, I started a similar thread in the HTML forums in case they knew anything more. But to be quite honest, I'm not sure who I should be asking about this.

I'm getting frustrated by this so I think I'll let it lie for a while and do something else. Knowing my luck it'll end up being something really obvious that I've over looked because I've been overthinking it.

Sep 29 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.