how to get list of objects via requestbody in spring boot api -
to list of objects via @requestbody
in controller , process each object in list
business logic.
i have tried not working
@requestmapping(value="/updateservicetype", method=requestmethod.post,produces="application/json") public @responsebody servicetypesmessage updateservicetype(@requestbody list<barberservicetype> servicetypes,final httpservletresponse response){
also tried following:
@requestmapping(value="/updateservicetype", method=requestmethod.post,produces="application/json") public @responsebody servicetypesmessage updateservicetype(@requestbody barberservicetype[] servicetypes,final httpservletresponse response){
below works me
@requestmapping(value = "/payments", method = requestmethod.post, consumes = mediatype.application_json_value, produces = mediatype.application_json_value) public @responsebody list<payment> batchcreate(@requestbody list<payment> payments) { return paymentservice.create(payments); }
you need jackson in class path
<dependency> <groupid>com.fasterxml.jackson.core</groupid> <artifactid>jackson-databind</artifactid> <version>2.6.0</version> </dependency>
json in put is
[{"sort":"10-20-30","account":"1234"},{"sort":"10-20-30","account":"1234"}]
Comments
Post a Comment