I know that there is a lot of similar questions, but none of them helps me.
on server i hav method:
@RequestMapping(value = "/event", method = RequestMethod.POST , produces = MediaType.APPLICATION_JSON_VALUE)
public void bookOpened(
@RequestParam(value="id", required = true) int id,
@RequestParam(value="type", required = true) String type,
HttpServletRequest request, HttpServletResponse response, HttpSession httpSession) {
}
and on the clien side i send a request:
var xhr = new XMLHttpRequest();
xhr.open('POST', '/event');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onload = function() {
if (xhr.status === 200) {
var userInfo = JSON.parse(xhr.responseText);
console.log(userInfo);
}
};
xhr.send(JSON.stringify({
id: 1,
type: 'BOOK_VIEWED'
}));
requests end with error 400(bad request) and i dont know why