Results 1 to 2 of 2

Thread: Content-Type not staying set in a MSXML2.ServerXMLHTTP object

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2007
    Location
    Middletown, CT
    Posts
    948

    Angry Content-Type not staying set in a MSXML2.ServerXMLHTTP object

    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

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2007
    Location
    Middletown, CT
    Posts
    948

    Re: Content-Type not staying set in a MSXML2.ServerXMLHTTP object

    I was posting to the wrong url. It should have been xlDocs/user/login.

    For the reference of others: this is a Drupal web service to which I am connecting. Still the same error, though.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width