I'm trying to send a POST request to Sprin boot with a list of custom objects in the body. My JSON in request body is this:
[{"name":"name1","icon":"icon1"},
{"name":"name2","icon":"icon2"},
{"name":"name3","icon":"icon3"}]
And I get this error
Cannot construct instance of `io.wedaily.topics.models.Topic` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
My controller:
@PostMapping
public void createTopics(@RequestBody List<Topic> topics) {
System.out.println(topics);
}
My Topic Model:
public class Topic {
private Long id;
private String name;
private String icon;
private Date createdAt;
// Constructor
// Getters
// Setters
}