title: Error 415 when posting JSON data to WCF Service
body: <p>I am trying to send some JSON data to a service I have created in c# and wcf. In Fiddler my POST request is as follows</p>
  
  <p>Fiddler:</p>
  
  <pre><code>Request Header
  User-Agent: Fiddler
  Host: localhost
  Content-Length: 29
  Content-Type: application/json; charset=utf-8
  
  Request Body
  {sn:"2705", modelCode:1702 } 
  </code></pre>
  
  <p>Below is the service interface. That uses the WebInvoke attribute to manage the POST request</p>
  
  <pre><code>[ServiceContract]
  public interface IProjectorService
  {
      [WebInvoke(Method="POST", UriTemplate="projectors", RequestFormat=WebMessageFormat.Json, ResponseFormat=WebMessageFormat.Json )]
      [OperationContract]
      void RecordBreakdown(Record record);
  }
  </code></pre>
  
  <p>The implementation of the service interface takes the variables passed in to the argument and uses ado to send this data to a SQL db.</p>
  
  <pre><code>[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
  [ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]
  public partial class ProjectorService : IProjectorService
  {
  
      public void RecordBreakdown(Record record)
      {
          //ado code to send data to db (ie do record.SerialNumber...
      }        
  }
  </code></pre>
  
  <p>POCO object to represent the multiple parameters</p>
  
  <pre><code>[DataContract]
  public class Record
  {      
      [DataMember]
      public string SerialNumber { get; set; }
      [DataMember]
      public int ModelCode { get; set; }
  }
  </code></pre>
  
  <p>.svc file</p>
  
  <pre><code>&lt;%@ ServiceHost Language="C#" Debug="true" Service="ProjectorService" CodeBehind="~/App_Code/ProjectorService.cs" %&gt;
  </code></pre>
  
  <p>Web.config:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;appSettings&gt;
      &lt;add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/&gt;
    &lt;/appSettings&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.5"/&gt;
      &lt;httpRuntime targetFramework="4.5"/&gt;
    &lt;/system.web&gt;
    &lt;system.serviceModel&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior&gt;
            &lt;serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/&gt;
        &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;protocolMapping&gt;
        &lt;add binding="basicHttpsBinding" scheme="https"/&gt;
      &lt;/protocolMapping&gt;
      &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/&gt;
    &lt;/system.serviceModel&gt;
    &lt;system.webServer&gt;
      &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
      &lt;directoryBrowse enabled="true"/&gt;
    &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>In fiddler, when I click on "execute", I receive an error 415 "unsupported media type". My current line of thought is that in my Projector service class, maybe im supposed to create a response object and send the 200 code back?!</p>