Binding to an JSON Object
1.in the body select raw.
2.add the following JSON object
{
"duration" : 55,
"desc" : "running"
}
3. In the header set up the Accept (accept is set up for the producer) to : Application/json and Content-Type ( set up for the consumer) : application/json
4. Click send will get the the following
{
"desc": "running",
"duration": 55
}
@POST
@Path("activity")
@Consumes(MediaType.APPLICATION_JSON)
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Activity createActivity(Activity activity){
System.out.println(activity.getDescription());
activityRepository.create(activity);
return activity;
}