My course pojo is ;
public class Course {
private int cid;
private String name;
private String code;
private int credit;
//Getters Setters
}
service :
@RequestMapping(value="/addcourse" , method=RequestMethod.POST)
public @ResponseBody Response<Course> addCoursetoUser(@RequestBody Course course, @RequestBody User user) throws SQLException{
if(new CourseDAO().addCoursetoUser(course, user))
return new Response<>(...);
else
return new Response<>(...);
}
i am trying to send this json values to my web service, but i am getting this error : org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "cid" (Class com.spring.model.Course), not marked as ignorable
{
"id" :3,
"name" : "Algorithms",
"code" : "COM367",
"credit" : 3,
"cid" : 28,
"username" : "selin",
"password" : "ssgg"
}
I have tried a lot of jsons but I always get this error. Thanks in advance..
You can't. You will need to wrap your two objects into a single object (maybe CourseUser
or CourseUserRequest
).
Also that error implies your Course
class is missing the cid
field in the Java model.