Я отправил правильное тело в формате JSON от Почтальона.
{
"loginId": "xxxxxx",
"password": "xxxxxx",
"clientIP": "xxxxx",
"companyId": "xxxxx"
}
Это мой контроллер
@RestController
@RequestMapping(path = "/umm")
public class LoginServer {
private transient Logger log = LogManager.getLogger(this.getClass());
@RequestMapping(value = "/basicLogin",method = RequestMethod.POST)
public @ResponseBody LoginRequest login(@RequestBody(required = true) LoginRequest loginRequest){
return null;
}
}
А это мой домен
public class LoginRequest implements Serializable {
private static final long serialVersionUID = -884241731093688658L;
private String loginId;
private String password;
private String clientIP;
private String companyId;
public LoginRequest(String loginId, String password, String clientIP, String companyId) {
this.loginId = loginId;
this.password = password;
this.clientIP = clientIP;
this.companyId = companyId;
}
//getter and setter omitted
}
Я не знаю, почему он возвращает мне код ошибки 400 (неверный запрос), потому что я отправил правильное тело JSON
Это ответное сообщение.
{
"timestamp": 1549458416991,
"status": 400,
"error": "Bad Request",
"exception": "org.springframework.http.converter.HttpMessageNotReadableException",
"message": "JSON parse error: Can not construct instance of escf.api.domain.login.LoginRequest: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of escf.api.domain.login.LoginRequest: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?)\n at [Source: java.io.PushbackInputStream@1c360a55; line: 2, column: 2]",
"path": "/umm/basicLogin"
}
Мне нужноверните мне код 200.