I am developing a SpringBoot Application. For a POST end-point, there is NO request body to be passed. My service is working fine. But its also working when I pass some values in the body of the request. How can I validate and return a BAD REQUEST if something is passed in the body of request which should ideally remain empty for this request?
*@RequestMapping(value = "/sample/customers", method = POST)
public Customer session() {
return customerService.getCustomer();
}*
You should not use POST for data retrieval.
You'll need 2 methods. Here is an example code for the save: