title: request.ContentType = "application/json" gives bad request error on WCF method
body: <p>I have created a WCF service using <a href="http://visualstudiogallery.msdn.microsoft.com/fbc7e5c1-a0d2-41bd-9d7b-e54c845394cd" rel="nofollow">WCF REST Service Template 40(CS)</a>  and method header looks like this:</p>
  
  <pre><code>[WebInvoke(UriTemplate = "CTNotification", Method = "POST", ResponseFormat = WebMessageFormat.Json,
            RequestFormat = WebMessageFormat.Json)]      
  
  public string CTNotification(Stream contents)
  </code></pre>
  
  <p>and here is how I am using it:</p>
  
  <pre><code> string url = ConfigurationManager.AppSettings["serviceUrl"];                  
   string requestUrl = string.Format("{0}CTNotification", url);
  
   HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(requestUrl);
   request.Method = "POST";
   request.ContentType = "application/json";
   //request.ContentType = "text/plain"; 
   request.Timeout = 5000000;                
  
   byte[] fileToSend = File.ReadAllBytes(Server.MapPath("~/json.txt"));
   request.ContentLength = fileToSend.Length;
  
   using (Stream requestStream = request.GetRequestStream())
   {
       // Send the file as body request.
       requestStream.Write(fileToSend, 0, fileToSend.Length);
       requestStream.Close();
   }
  
   using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
       Console.WriteLine("HTTP/{0} {1} {2}", response.ProtocolVersion, (int)response.StatusCode, response.StatusDescription);
  
   Label1.Text = "file uploaded successfully";
  </code></pre>
  
  <p>It gives bad error 400. but if it make the content type plain, it works but I want to pass json which is stored in json.txt. Please suggest me how to do it ?</p>
  
  <p>Thanks.</p>