I have a springboot rest controller:
@RestController
public class UserController {
@Autowired UserRepository userRepository;
@RequestMapping(value = "/account/{userid:.+}", method = RequestMethod.GET)
public HttpEntity<Account> getAccountByUserId(@PathVariable String userid) {
if(userid == null) {
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
Account user = userRepository.findOneByUserid(userid.toLowerCase());
if(user == null) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
return new ResponseEntity<>(user, HttpStatus.OK);
}
}
Note the @PathVariable definition is slightly weird because Spring MVC @PathVariable with dot (.) is getting truncated.
This call works perfectly and i receive a 200 status code with lovely json: http://.../account/scarlett.j@myplace.com
However this call http://.../account/scarlett.j@myplace.com.au returns status code 406 and debug logs show the message "org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation"
Why and how do i fix it? Thanks.