I have the following code in REST, Spring MVC. This code should return a JSON data structure called ResponseText:
@RequestMapping(value="/movieTheater", headers = {"ACCEPT=*/*"}, method=RequestMethod.GET) public @ResponseBody ResponseText getCustomerInput(@RequestParam("name") String name, @RequestParam("price") Double price) { Transaction transaction = new Transaction(); ResponseText result = new ResponseText(); transaction.setMovieName(name); transaction.setTicketPrice(price); transaction.setDatetime(new Date()); if(transactionService.addTransaction(transaction)) result.setMessage(ResponseStatus.SUCCESS.getStatus()); else result.setMessage(ResponseStatus.FAILED.getStatus()); return result; }
But when I execute this code through the below URL in the browser, I get the following error:
URL:
http:
Error:
HTTP Status 406 - type Status report message description The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.
I cannot determine what I am doing wrong here. I looked on the web explaining this error, but still do not know what I am missing. I gave ACCEPT = "/" which should cover all kinds of answers, right? Please help! Thanks in advance!
** When I added the title
headers={"Accept: application/json, text/javascript"}
instead of the above, I got the following error:
HTTP Status 405 - Request method 'GET' not supported
source share