hi,
i've a students class, which is of the form
request format:
students: [
{
"studentid" : "1234",
"researchid" : "5689",
"courses ": [{
"courseName" : "os",
"professorName": "donchi lee"
},
{
"courseName" : "database",
"professorName": "jie, joe"
}]
"exams": [{
/*example data */
}]
}
]
lass foo { public List<StudentList> students { get; set; } } class StudentList { public string studentid { get; set; } public string researchId { get; set; } public List<courses> courseList { get; set; } public List<examsschedule> exams { get; set } } class courses { public string courseId { get; set; } public string courseName { get; set; } public string professsorName { get; set; } } class exams { /****/ }
I
have to post this as json to api. postasjsonasynch
When I send object of "foo" class, api rejects as it is not as json format.
var payload = fooObject/*object of foo*/var httpContent =newStringContent(payload,Encoding.UTF8,"application/json");
var httpresponse = httpclient.HttpClient.PostAsJsonAsync("url", httpcontent);
this returns either invalid format. if i use json serializer, it throws error as can not be serialized
I'm using web api's postasjsonaynch
[jsonproperty] is this used only for capturing response or also building request ?