My Map<String, Object>
parameter is throwing a 400 bad request error
with the following message, Cannot convert value of type 'java.lang.String' to required type 'java.util.Map' for property 'data'
and I am not sure why?
In my postman, I go to Body
then form-data
and I place data
under Key
then I place the following value { "key": "value" }
.
My model with the request parameter and controller:
public class RequestModel {
@Schema(type = "object")
private Map<String, Object> data;
private MultipartFile file;
private String requestId;
private String date;
}
public class Controller {
@PostMapping(value = "/send", produces = { MediaType.APPLICATION_JSON_VALUE }, consumes = {
MediaType.MULTIPART_FORM_DATA_VALUE })
public ResponseEntity<Response> send(@ModelAttribute final RequestModel model) {
var response = service.send(model);
return ResponseEntity.ok(response);
}
}
All my other parameters is able to get pass fine, except for the Map
.