I followed this example, which allows to post a unique Person
object. I want a REST service where I can post a collection of Person
at once, e.g. a
@RequestMapping(method=RequestMethod.POST, value="/batchInsert", consumes = "application/json", produces = "application/json")
@ResponseBody
public ResponseEntity> batchInsert(@RequestBody Resources people, PersistentEntityResourceAssembler assembler) throws Exception {
Iterable s = repo.save( people.getContent() ); // save entities
List list = new ArrayList();
Iterator itr = s.iterator();
while(itr.hasNext()) {
list.add( assembler.toFullResource( itr.next() ) );
}
return ResponseEntity.ok( new Resources(list) );
}