08-02-2023, 01:18 PM
I need to pass a list of values in the request body of `POST` method but I get `400: Bad Request error`.
Below is my sample code:
@RequestMapping(value = "/saveFruits", method = RequestMethod.POST,
consumes = "application/json")
@ResponseBody
public ResultObject saveFruits(@RequestBody List<String> fruits) {
...
}
The JSON I am using is: `{"fruits":["apple","orange"]}`
Below is my sample code:
@RequestMapping(value = "/saveFruits", method = RequestMethod.POST,
consumes = "application/json")
@ResponseBody
public ResultObject saveFruits(@RequestBody List<String> fruits) {
...
}
The JSON I am using is: `{"fruits":["apple","orange"]}`