title: Trouble with MultiPart/Form-Data as a web request
body: <p>I have a HTML POST request which i need to replicate in c#</p>
  
  <p>The HTML is something like</p>
  
  <pre><code>&lt;FORM action="http://RemoteServerURL" enctype="multipart/form-data" method=POST&gt;
      &lt;TEXTAREA id="TextAreaXML" name="xmlmsg" rows="20" cols="100"&gt;   &lt;/TEXTAREA&gt;
      &lt;button type="submit"&gt;Send&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The TextArea Expects an inout which is as below</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;OnlineCheck&gt;
    &lt;Header&gt;
      &lt;BuyerAccountId&gt;XXXXXX&lt;/BuyerAccountId&gt;
      &lt;AuthCode&gt;XXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&lt;/AuthCode&gt;
      &lt;Type&gt;STOCK&lt;/Type&gt;
    &lt;/Header&gt;
    &lt;Item line="1"&gt;
      &lt;ManufacturerItemIdentifier /&gt;
      &lt;DistributorItemIdentifier&gt;3109750&lt;/DistributorItemIdentifier&gt;
      &lt;Quantity&gt;7&lt;/Quantity&gt;
    &lt;/Item&gt;
  &lt;/OnlineCheck&gt;
  </code></pre>
  
  <p>This Part works Fine.</p>
  
  <p>Now i tried to replicate it in c# like below.</p>
  
  <pre><code>WebRequest req = WebRequest.Create("http://RemoteServerURL");
  string xmlmsg = "&lt;?xml version=" + '"' + "1.0" + '"' + " encoding==" + '"' + "utf-8" + '"' + "?&gt;&lt;OnlineCheck&gt;&lt;Header&gt;&lt;BuyerAccountId&gt;XXXXXX&lt;/BuyerAccountId&gt;&lt;AuthCode&gt;XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX&lt;/AuthCode&gt;&lt;Type&gt;STOCK&lt;/Type&gt;&lt;/Header&gt;&lt;Item line=" + '"' + "1" + '"' + "&gt;&lt;ManufacturerItemIdentifier /&gt;&lt;DistributorItemIdentifier&gt;3109750&lt;/DistributorItemIdentifier&gt;&lt;Quantity&gt;7&lt;/Quantity&gt;&lt;/Item&gt;&lt;/OnlineCheck&gt;";
  
  byte[] send = Encoding.Default.GetBytes(xmlmsg);
  req.Method = "POST";
  req.ContentType = "multipart/form-data";
  req.ContentLength = send.Length;
  
  Stream sout = req.GetRequestStream();
  sout.Write(send, 0, send.Length);
  sout.Flush();
  sout.Close();
  
  WebResponse res = req.GetResponse();
  StreamReader sr = new StreamReader(res.GetResponseStream());
  string returnvalue = sr.ReadToEnd();
  </code></pre>
  
  <p>This fails and I get the message </p>
  
  <blockquote>
    <p>"The request was rejected because no multipart boundary was found XML
    request"</p>
  </blockquote>
  
  <p>. So i know the request to the server is working. But the input or something is going wrong. Please Help</p>