i have created a web API and i have used list of object as parameter in HttpResponseMessage, its working from Postman (saving data in Sql server DB)
how to pass that json data from vs 2010 webform
can u please help me
[HttpPost]
public HttpResponseMessage PatDet([FromBody]List<Patient> patientDetails)
{
try
{
if (patientDetails.Count == 0)
{
return Request.CreateResponse(HttpStatusCode.OK, "No Records Found");
}
return Request.CreateResponse(HttpStatusCode.OK, d.InsertPatDetails(patientDetails));
}
catch (Exception ex)
{
ErrorLog.WriteError(ex.ToString());
//throw ex;
return new HttpResponseMessage(HttpStatusCode.InternalServerError);
}
}
[
{
"FirstName": "xyz kumar",
"DateOfBirth": "1996-06-07",
"LastName": "",
"Gender": "M",
"Id": "4567YTRTYU",
"Mobile": "9999999999",
"KIN": [
{
"Name": "aghvd dsds",
"Visits": [
{ "date": "2020-06-24T00:00:00" },
{ "date": "2020-06-26T00:00:00" },
{ "date": "2020-06-28T00:00:00" }
]
}
]
},
{
"FirstName": "abc",
"DateOfBirth": "1996-06-07",
"LastName": "",
"Gender": "F",
"PatientId": "4567YTYU",
"Mobile": "",
"KIN": [
{
"Name": "hdbcsj jshd",
"Visits": [
{ "date": "2020-07-02T00:00:00" },
{ "date": "2020-07-10T00:00:00" },
{ "date": "2020-07-18T00:00:00" },
{ "date": "2020-07-26T00:00:00" }
]
}
]
}
]