title: VB.NET post XML via http
body: <p>I've got good working code in VB6. But I need to post xml file utf-8 encoded (cyrilic included). So i would like to convert code to VB.NET, but result is error 500 - internal server error</p>
  
  <p>Original vb6 code (succesfull witchout cyrilic):</p>
  
  <pre><code>Dim o As New xmlHttp
  xmlContent() = fs.GetFileContent(Replace(Me.txtOutputFileName.Text, fs.GetFileNameByPath(Me.txtOutputFileName.Text), "") &amp; xmlFileNames(i))
    xmlString = MFunctions.GetString(xmlContent())
  o.Open "POST", server, False, EE_XML_EXCHANGE_ID, EE_XML_EXCHANGE_PWD
    o.setRequestHeader "Content-Type", "text/xml" ' "text/xml;charset=utf-8"
    o.setRequestHeader "SOAPAction", ""
    o.send xmlString
    Me.txtResponseHeaders = o.getAllResponseHeaders
    Me.txtResponse = o.responseText
  </code></pre>
  
  <p>VB.NET code (return error 500 - internal server error):</p>
  
  <pre><code>Dim xdoc As XDocument = XDocument.Load("z:\Operations\RU\_TEST\xml\send\RUWP121001_01_05_01.xml")
      Dim request As WebRequest = WebRequest.Create("http://217.159.234.77:8080/epmx/services/messagesService")
  
      request.Method = "POST"
      Dim postData As String = xdoc.ToString
      Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
      request.ContentType = "text/xml"
      request.ContentLength = byteArray.Length
      request.Credentials = New System.Net.NetworkCredential(EE_XML_EXCHANGE_ID,EE_XML_EXCHANGE_PWD)
  
      Dim dataStream As Stream = request.GetRequestStream()
      dataStream.Write(byteArray, 0, byteArray.Length)
      dataStream.Close()
  
      Dim response As WebResponse = request.GetResponse()
      Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)
      dataStream = response.GetResponseStream()
      Dim reader As New StreamReader(dataStream)
      Dim responseFromServer As String = reader.ReadToEnd()
      Console.WriteLine(responseFromServer)
      reader.Close()
      dataStream.Close()
      response.Close()
  </code></pre>
  
  <p>Have got any idea what's the problem?</p>
  
  <p>Thank you</p>