The front end sends this json to my API
{
"parameters":{
"MAIL_BODY":"saffsa",
"MAIL_FROM":"sffasafs",
"MAIL_RECEIVED_DATE":"asfasf",
"MAIL_SUBJECT":"asfafs",
"MAIL_TO":"ssfafs"
},
"templateID":"9093",
"deliveryChannel":"NONE"
}
Controller:
@RequestMapping(value = "/previewDocument", method = RequestMethod.POST, produces = "application/pdf")
public byte[] previewDocument(@RequestBody Map<String, String> parameters, @RequestBody String templateID, @RequestBody String deliveryChannel) {
// TODO
}
But i'm getting this on my backend logs
2019-02-22 10:34:55.068 WARN 9976 --- [nio-8083-exec-7] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of
java.lang.Stringout of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance ofjava.lang.Stringout of START_OBJECT token at [Source: (PushbackInputStream); line: 1, column: 15] (through reference chain: java.util.LinkedHashMap["parameters"])]
I don't understand what is the issue. parameters seems to be a Map right? Can someone explain me why this does not work?
Map<String, String> parameters; String templateId; String deliveryChanneland then use that as the sole parameter annotated with@RequestBody- Lino