I am using Spring boot and I need to pass JSON list in @RestController using ResponseEntity:
@RequestMapping(value = "", method = RequestMethod.GET)
public ResponseEntity getCustomers() {
List<Customer> customerJsonList = new ArrayList();
List<CustomerTable> customerList = (List<CustomerTable>) customerRepository.findAll();
for(CustomerTable customerTable : customerList) {
Customer customer = new Customer();
customer.setId(customerTable.getId());
customer.setFirstname(customerTable.getFirstname());
customer.setLastname(customerTable.getLastname());
customer.setAddress(customerTable.getAddress());
customerJsonList.add(customer);
}
return ResponseEntity.ok(customerJsonList);
}
When I tried to test in postman I get an empty body. When I tried in Chrome browser I am getting:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon Dec 11 10:19:54 AEDT 2017 There was an unexpected error (type=Not Acceptable, status=406). Could not find acceptable representation