@RequestMapping(method = RequestMethod.PUT, value = "/add/{label}/{amount}") public void addEarning( @PathVariable String label, @PathVariable int amount, HttpServletResponse response) throws JsonGenerationException, JsonMappingException, IOException { log.info("Add new earnings..."); long id = earningsService.addEarning(label, amount, null); response.setContentType(MediaType.APPLICATION_JSON_VALUE); new ObjectMapper().writeValue(response.getOutputStream(), id); }