@RequestMapping( method = RequestMethod.POST, consumes = {MediaType.APPLICATION_JSON_VALUE}, produces = {MediaType.APPLICATION_JSON_VALUE}) public Note create(@RequestBody Note note) { if ("Ошибка".equals(note.getTitle())) throw new BadTitleException(); return noteRepository.save(note); }