I have a Spring Boot server application that receives a POST request from an external service with the following characteristics:
Headers
accept-encoding: gzip,deflate
user-agent: Apache-HttpClient/4.3.6 (java 1.5)
connection: Keep-Alive
host: webhook.site
content-type: application/x-www-form-urlencoded
content-length: 558
Query strings: (empty)
Form values
BillNumber: 41492032464
BillValue: 600000.0
Description: Description
To be able to handle this POST request from the external service I implemented the following controller, which what it does is create and store an invoice, but my application returns an HTTP Error 406:
@RequestMapping(value = "/bills", method = RequestMethod.POST, headers = "Accept=application/x-www-form-urlencoded")
@ResponseBody
@Transactional
public void createBill(UriComponentsBuilder uriComponentsBuilder,
final HttpServletRequest request,
final HttpServletResponse response) throws IOException {
}
I understand that the error refers to the client (in this case the external service) does not understand the "language" of the server response, but as you can see in the headers of my controller I am accepting "application / x-www-form -urlencoded". I do not know if it's due to another problem also my controller it's void.
How should this controller be implemented in my spring boot app?