Getting the following exception for Spring Rest controller webservices :-
org.springframework.web.client.HttpClientErrorException: 415 Unsupported Media Type at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91) at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:667)
Code:
public class PaymentProcessController {
@RequestMapping(value = "/payment_failure", method = RequestMethod.POST)
public ModelAndView savePayFailure(HttpServletRequest request, HttpServletResponse response, HttpSession session)
{
RestTemplate restTemplate = new RestTemplate();
Invoice invoice = restTemplate.getForObject(
"http://localhost:8080/rooftop/invoice/findByProperty/TRANASACTION_NO/" + tx
nid, Invoice.class);
}
The REST client is written in InvoiceRestController as below :
InvoiceRestController:
@RestController @RequestMapping(value = "/invoice/")
public class
InvoiceRestController { @RequestMapping(value =
"/findByProperty/{property}/{value}", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE, consumes =
MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Invoice> findByProperty(@PathVariable String property, @PathVariable String value) throws Exception {
}