EN
Spring - HTTP Status 415 - The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.
1
answers
1
points
I have created some controller that returns some result for indicated GET REST action:
http://localhost:8080/rest/description
With jQuery AJAX GET method it works perfectly, but when I tried to open same url from browser I got following problem:
HTTP Status 415 -
type Status report
message
description The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.
Apache Tomcat/8.0.46
Screenshot:
My controller looks following way:
@Controller
public class PostMainRestController {
@RequestMapping(
value = "/rest/description",
method = RequestMethod.GET,
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE
)
@ResponseBody
@Transactional(readOnly = true)
public String getDescription(HttpServletRequest request) {
return "[\"This is my description.\"]";
}
}
1 answer
3
points
The problem is related with your consumes
parameter.
GET method is used and you send nothing.
Remove consumes
. Check below solution:
@Controller
public class PostMainRestController {
@RequestMapping(
value = "/rest/description",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE
)
@ResponseBody
@Transactional(readOnly = true)
public String getDescription(HttpServletRequest request) {
return "[\"This is my description.\"]";
}
}
0 comments
Add comment