I have path variable parameter as a UUID, with path as id.
@RequestMapping(method = RequestMethod.GET, path = "/{id}", produces = "application/json")
public ResponseEntity<T> getId(@PathVariable("id") final UUID id) {
}
when I add this as a String4df34f48-33ce-4da2-8eba-a682e2d1e698
or as String in brackets{4df34f48-33ce-4da2-8eba-a682e2d1e698}
in my postman url, I get a 400 Bad Request error.
What can I do to add it here?
Thanks.
CodePudding user response:
You need to have @PathVariable
as part of the function itself:
@RequestMapping(method = RequestMethod.GET, path = "/{id}", produces = "application/json")
public ResponseEntity<UUID> getUID(@PathVariable("id") final UUID id) {
log.info("id is {}", id);
return new ResponseEntity<>(id, HttpStatus.OK);
}
That should then allow you to query it through Postman:
http://localhost:8080/4df34f48-33ce-4da2-8eba-a682e2d1e698