Reputation: 271
I have updated the pathvariable from String to UUID in the controller of a spring-boot implemented web application. I am using swagger for the front end. I am getting "Missing URI template variable 'uuid' for method parameter of type UUID" exception in the response after the change.
I have updated the pathvariable from String to UUID in the controller of a spring-boot implemented web application. I am using swagger for the front end. At the db side I am using mongodb. I am converting this uuid to string to use the exiting find method implemented for mongodb. I am getting this exception in the response. The same thing is working in another project, Couldn't find out why it is not working here.
@Path("/uuid")
@RequestMapping(value = "/uuid", method = { RequestMethod.GET })
@ResponseBody
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "Retrieves result based on Unique Identifier", notes = "Returns result matching with the Unique Identifier",
position = 1, response = Response.class, httpMethod = "GET")
@ApiResponses(value = { @ApiResponse(code = HttpServletResponse.SC_BAD_REQUEST, message = "Invalid request."),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "Record not found."),
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Not authorized for this operation."),
@ApiResponse(code = HttpServletResponse.SC_CONFLICT, message = "Object state out-of-date."),
@ApiResponse(code = HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message = "Server error") })
ResponseEntity<Response> getResultByUuid(@ApiParam(required = true, name = "uuid", value = "uuid") @PathParam("uuid") @PathVariable("uuid") UUID uuid,
@ApiParam(access = "hidden") HttpServletRequest request)
throws IOException;
Upvotes: 3
Views: 3527
Reputation: 662
Path variable must be mentioned in the request mapping in curly brackets. In your code the following line
@RequestMapping(value = "/uuid", method = { RequestMethod.GET })
can be changed to
@RequestMapping(value = "/{uuid}", method = { RequestMethod.GET })
to fix that error.
Upvotes: 2