rest - Why do i get HttpMediaTypeNotAcceptableException? -
i have 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 @pathvariable definition weird because spring mvc @pathvariable dot (.) getting truncated.
this call works , receive 200 status code lovely json: http://.../account/scarlett.j@myplace.com
however call http://.../account/scarlett.j@myplace.com.au returns status code 406 , debug logs show message "org.springframework.web.httpmediatypenotacceptableexception: not find acceptable representation"
why , how fix it? thanks.
Comments
Post a Comment