I have written a WCF REST service.My Get method would return a list values..When I execute my xml response is :
How ever when I tried the same with JSON response Iam getting like :
bf98bd3b-dccc-442d-ab4b-0bad4ecbdfd7Care919 12:0013:00 10
i.e JSON response is not clear..I want the response in
"AppointmentList":[
{
"AppointmentEndTime":"19 ",
"AppointmentStartTime":"9",
"BreakEndTime":"13:00",
"BreakStartTime":"12:00",
"CompanyId":"bf98bd3b-dccc-442d-ab4b-0bad4ecbdfd7",
"CompanyName":"Care",
"Interval":"10"
}
]
How can I get a clear response like this in JSON format?
IService.cs:
[OperationContract]
[WebInvoke(UriTemplate = "GetAppointments/?companyId={companyId}&appointmentDate={appointmentDate}", Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
GetAppointmentList GetAppointment(Guid companyId, string appointmentDate);
Service1.cs :
public GetAppointmentList GetAppointment(Guid companyId, string appointmentDate)
{
SQLDataContext context = new SQLDataContext();
var getappointment = context.GetAppointmentTimings(companyId,appointmentDate);
GetAppointmentList getappointmentlist = new GetAppointmentList();
getappointmentlist.AppointmentList = new List
foreach (var r in getappointment.ToList())
{
Company company = new Company();
company.CompanyId = r.CompanyId;
company.CompanyName = r.CompanyName;
company.BreakStartTime = r.BreakStartTime + ":" + "00";
company.BreakEndTime = r.BreakEndTime + ":" + "00";
company.Interval = r.Interval;
company.AppointmentStartTime = r.AppointmentStartTime;
company.AppointmentEndTime = r.AppointmentEndTime;
getappointmentlist.AppointmentList.Add(company);
}
return getappointmentlist;}
Ehsan HafeeezPosted Sep 25, 2012, 4:57 AM
Sukesh MarlaPosted Sep 9, 2012, 8:40 AM
Also post the code you are using to Access the Service,
Check this is correct answer if it helped.