4

When I am passing email address as path variable it is throwing following error

 Console --> 2015-02-09 16:30:06,634 WARN - GET request for "http://localhost:8181/abc/users/[email protected]" resulted in 406 (Not Acceptable); invoking error handler Exception in thread "main" org.springframework.web.client.HttpClientErrorException: 406 Not Acceptable at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91) at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:607) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:565) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:521) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:439) at RestClient.main(RestClient.java:35) 

I have tried lots of cases, so I finally found the problem with last domain like .com and .org which are internationalize domains. So instead of "[email protected]" if I pass "[email protected]" it will work perfectly fine.

My code is

@RequestMapping(value = "users/{emailId:.*}", method = RequestMethod.GET) public Object searchUser(@PathVariable("emailId") String emailId){ logger.info("Inside search user --> emailId " + emailId); return userService.findUserByuserId(emailId); } 
2
  • Hello I am also having the same issue. Have you already solved it..? Please help if yes. Vary true its working fine for .dom. Commented May 28, 2015 at 7:51
  • Hi Saurabh, I found a work around, Have a look at my answer, it should help you. Commented May 29, 2015 at 7:33

1 Answer 1

4

I found no answer to this. I think it's an http rule we can't have domains at last in prameters and can make a request.

So work around to this is just pass a slash at the end of the url and there you go.

Like modify "http://localhost:8181/abc/users/[email protected]/" with "http://localhost:8181/abc/users/[email protected]". And thanks to spring rest architecture, it will automatically omit the last slash and you will get "[email protected]" as a parameter value.

Let me know if you guys find something else.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.