I develop a Spring MVC application with a REST API.
I have this method in a controller :
@RequestMapping(value="/roomId/{roomId}",produces = "application/json")
public List<DayStatisticDto> findBySiteAndRoom(@PathVariable("roomId") String roomId, @RequestParam("timestamp") String timestamp, @RequestParam("pageSize") Integer pageSize) throws ParseException {
List<DayStatisticDto> dayStatisticDtos = dayStatisticService.latestDailyStatisticsForRoom(getCurrentUserSiteCode(), roomId, pageSize, timestamp, false);
return dayStatisticDtos;
}
When I make this get request :
With this request parameters :
- Accept:application/json
- Accept-Encoding:gzip, deflate, sdch, br
- Accept-Language:fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
- Cache-Control:no-cache
- Cookie:_ga=GA1.1.486025197.1475764350;JSESSIONID=6716A5824088BC0F46A6B74D5FB25A3E
- Host:localhost:8080
- User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36
I get a correct JSON object as response.
But when I change the parameter "roomId" from I1.A.122 to I1.A.123 :
With this request parameters :
- Accept:application/json
- Accept-Encoding:gzip, deflate, sdch, br
- Accept-Language:fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
- Cache-Control:no-cache
- Cookie:_ga=GA1.1.486025197.1475764350; JSESSIONID=6716A5824088BC0F46A6B74D5FB25A3E
- Host:localhost:8080
- User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36
I receive a error code 406 - Inacceptable
I use this kind of request everywhere in the projet and I never had this kind of issue. The parameter "roomId" still a normal integer value. How can it generate issue with Spring Mvc ? The headers and the running code still exactly the same.
When I put a breakpoint at the first line of the "findBySiteAndRoom" method, in the first case it reaches the point. But in the second case, it returns the 406 error code before reaching the break point.
Thank you in advance for your help.