I need to avoid sending a note as a request param in a Post operation. To do so I need to move it from the url to the body but I don't know how.
Here is the code:
@PostMapping(value = "/person/{cuco_id}/notes/{typeNote}/**{note}**", produces = { "application/json; charset=UTF-8" }, consumes = {
"application/json; charset=UTF-8" })
@ApiOperation(value = "Create a new note for the specified Cuco ID", response = Note.class)
@Transactional
public ResponseEntity<Note> createNote(
@ApiParam(value = "Cuco ID for which the note should be created", required = true) @PathVariable Long cuco_id,
@ApiParam(value = "Type of note which should be created", required = true) @PathVariable String typeNote,
@ApiParam(value = "Note which should be added to the Cuco ID", required = true) @PathVariable String note,
@AuthenticationPrincipal Principal principal)
throws ElementAlreadyExistsException, ValidationErrorException, IOException {
// check if Note entity for cuco id exists
Integer seq = repo.findNextSeq(cuco_id,typeNote);
NotePK notePk = new NotePK(cuco_id, seq, typeNote);
Note coreEntity = new Note();
Optional<Note> optNote = repo.findById(notePk);
if (!optNote.isPresent()) {
coreEntity.setIdCuco(notePk.getIdCuco());
coreEntity.setSeq(seq);
coreEntity.setTypeNote(notePk.getTypeNote());
coreEntity.setNote(note);
coreEntity.setCreationDate(new Date());
coreEntity.setLastModDate(new Date());
coreEntity.setCreationBy(principal.getName());
coreEntity.setLastModBy(principal.getName());
} else {
// If it already exits, do nothing
throw new ElementAlreadyExistsException("The note already exists");
}