title: 400 Bad request - REST JSON c#
body: <p>I've created a C# WCF project, when I'm testing it using POSTMAN or Fiddler. I've received an error: "400 Bad Request". Also I've created an C# windows project to test, it is the same result as well. Here's my WCF Project.</p>
  
  <pre><code>[ServiceContract]
  public interface IService1
  {
  
      [OperationContract]
      [WebInvoke(Method = "POST",
          ResponseFormat = WebMessageFormat.Json,
          RequestFormat = WebMessageFormat.Json,
          BodyStyle = WebMessageBodyStyle.Wrapped,
          UriTemplate = "api/createpr.json")]
      PRApplication AddPR(RequestData rData);
  
  }
  </code></pre>
  
  <p>I'm using this code when testing.</p>
  
  <pre><code>            try
          {
              var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://localhost/WEB_Service_B1/Service1.svc/api/createpr.json");
              httpWebRequest.ContentType = "application/json; charset=utf-8";
              httpWebRequest.Method = "POST";
  
              using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
              {
                  string json = "{\"Test\"}";
  
                  streamWriter.Write(json);
                  streamWriter.Flush();
                  streamWriter.Close();
              }
  
              var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
              using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
              {
                  var result = streamReader.ReadToEnd();
              }
          }
          catch (Exception err)
          {
              MessageBox.Show(err.Message);
          }
  </code></pre>
  
  <p>Is there any problem also in my Web.config?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
      &lt;system.web&gt;
        &lt;compilation debug="true" targetFramework="4.0" /&gt;
        &lt;authentication mode="Windows" /&gt;
        &lt;pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/&gt;
      &lt;/system.web&gt;
    &lt;system.webServer&gt;
      &lt;directoryBrowse enabled="true"/&gt;
    &lt;/system.webServer&gt;
    &lt;system.serviceModel&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="WS_B1.Service1Behavior"&gt;
            &lt;serviceMetadata httpGetEnabled="true" /&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
        &lt;endpointBehaviors&gt;
          &lt;behavior name="web"&gt;
            &lt;webHttp/&gt;
          &lt;/behavior&gt;
        &lt;/endpointBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;services&gt;
        &lt;service name="WS_B1.Service1" behaviorConfiguration="WS_B1.Service1Behavior"&gt;
          &lt;endpoint address="" binding="webHttpBinding" contract="WS_B1.IService1" behaviorConfiguration="web"&gt;
            &lt;identity&gt;
              &lt;dns value="localhost"/&gt;
            &lt;/identity&gt;
          &lt;/endpoint&gt;
          &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/&gt;
        &lt;/service&gt;
      &lt;/services&gt;
    &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;</code></pre>
  </div>
  </div>
  </p>