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.
This SO does work for me: WCF REST Service JSON Post data
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.
The JSON data is this.
{
"ID": 639073,
"PatientFirst": "John",
"PatientLast": "Smith",
"Birthdate": "1/1/2000",
"PtEmail":"rdejournett@medfusion.com",
"Sex": "F",
"mrn": ""
}
I have an ApptData class which is this.
[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() { }
}
And the iContract is this. I want to use the stuff that is commented out.
[ServiceContract]
interface iContract
{
[OperationContract]
[WebInvoke(Method = "PUT", UriTemplate = "CheckinPUT", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
[OperationContract]
//Stream PatientCheckinWithDemos(ApptData data);
Stream PatientCheckinWithDemos(Stream streamdata);
}