Answer the question
In order to leave comments, you need to log in
What is the best way to pass a single parameter to a JSON Post?
Should I create a POJO with a single field and get it via @RequestBody or is it better to directly specify @RequestBody with Integer?
Like this for example
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
public void create(@AuthenticationPrincipal AuthenticatedUser authenticatedUser,
@RequestBody Integer clientId) {
clientService.add(authenticatedUser.getUser(), clientId);
}
Answer the question
In order to leave comments, you need to log in
If in the future it may be necessary to expand the set of transmitted fields, then using now POJO with one field, then you will have to rewrite less.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question