title: WCF PUT - JSON body to object
body: <p>This is my first REST service, basically it is a self hosted service that is listening on a port for a PUT call which will have a payload of JSON data.  I want to convert that to a native object, I thought the serializer could do it automatically but it's not working.  </p>
  
  <p>This SO does work for me:  <a href="https://stackoverflow.com/questions/5384303/wcf-rest-service-json-post-data">WCF REST Service JSON Post data</a> </p>
  
  <p>I can get the JSON data as a stream and output it to a log just fine, but now I am wondering if WCF can automagically put the JSON data to my object.</p>
  
  <p>The JSON data is this.</p>
  
  <pre><code>{
    "ID": 639073,
    "PatientFirst": "John",
    "PatientLast": "Smith",
    "Birthdate": "1/1/2000",
    "PtEmail":"rdejournett@medfusion.com",
    "Sex": "F",
    "mrn": ""
  }
  </code></pre>
  
  <p>I have an ApptData class which is this.</p>
  
  <pre><code>[DataContract]
  class ApptData {
      [DataMember]
      internal string ID = "";
  
      [DataMember]
      internal string PatientFirst = "";
      [DataMember]
      internal string PatientLast = "";
      [DataMember]
      internal string Birthdate = "";
      [DataMember]
      internal string PtEmail = "";
      [DataMember]
      internal string Sex = "";
      [DataMember]
      internal string mrn = "";
  
      public ApptData() { }
  }
  </code></pre>
  
  <p>And the iContract is this.  I want to use the stuff that is commented out.</p>
  
  <pre><code>[ServiceContract]
  interface iContract
  {
      [OperationContract]
  
  
      [WebInvoke(Method = "PUT", UriTemplate = "CheckinPUT", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
      [OperationContract]
      //Stream PatientCheckinWithDemos(ApptData data);
      Stream PatientCheckinWithDemos(Stream streamdata);
  
  }
  </code></pre>