I am trying to send a request to my service, but it does not work. I get it 400 Bad Request. I have GET requests that work fine in a single controller.
Here is a way:
@RequestMapping(value = "/assign", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public Form5398Obj arriveTrip(@PathVariable String siteId,
@RequestBody ErrorMsg anError) throws Exception {
System.out.println(anError.toString());
}
The java ErrorMessage class is as follows:
public class ErrorMsg {
private String code;
private String msg;
private String request;
public ErrorMsg(String code, String msg, String request)
{
this.code = code;
this.msg = msg;
this.request = request;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getRequest() {
return request;
}
public void setRequest(String request) {
this.request = request;
}
}
I didn’t configure anything. What else do I need to do to make it work? I am using JavaConfig, do I need to add any bean declarations?
I submit: with Content-Type: application / json
{
"code" : "101",
"msg" : "Hello Test",
"request" : "1"
}
source
share