Hi there,
I'm hoping this is fairly simple; I have a web service that I'm trying to access, and it takes form data.

For some reason I cannot set the header for content-type to x-www-form-urlencoded. The response I get from the server is a 406, unrecognized data type: text/plain. this seems to indicate that the header is not being set properly.

Even more odd, this packet isn't showing up in Fiddler (an HTTP debugger), so I can't see the raw packet.

This is from an Excel 2007 spreadsheet in VBA. Ultimately, this is going to validate a user using the sheet against their registration on my website. I will be calling other functions as well, once this begins to work.

I have tested this in a packet creator and it works fine, so I know it's not the service. Best I can tell, the header's not being set properly.

Any ideas?



vb Code:
  1. Private Sub loginUser(ByVal pr_Username As String, ByVal pr_Password As String)
  2.     txtURL = "http://www.simplebusinesssolutions.org/xlDocs/system/connect"
  3.     Dim dataToSend As String
  4.     dataToSend = "username=" & pr_Username & "&password=" & pr_Password
  5.  
  6.    
  7.     Dim XMLHttp As Object: Set XMLHttp = CreateObject("MSXML2.ServerXMLHTTP")
  8.    
  9.     XMLHttp.Open "POST", txtURL, False
  10.    
  11.     XMLHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  12.     XMLHttp.setRequestHeader "Accept", "*/*"
  13.     XMLHttp.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
  14.    
  15.     XMLHttp.send dataToSend
  16.    
  17.  Debug.Print XMLHttp.responseText
  18.  Set XMLHttp = Nothing
  19.  
  20.  
  21.  Exit Sub