0

I am trying to expose rest webservice using spring mvc 4. With these annotations in controller

  @RequestMapping(value = "/services/empservice", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
  public String testArgument(@RequestBody Employee employee){
      System.out.println("employee variable--->"+employee.getEmployeeID());
      return String.valueOf(20);
   }

  @PostMapping(value = "/services/empservices", produces = MediaType.APPLICATION_JSON_VALUE,headers = "content-type=application/x-www-form-urlencoded")
  public String testArguments(@RequestBody Employee emploee){
      System.out.println("employee variable--->"+employee.getEmployeeID());
      return employee.getEmployeeID();
   }

The response from WAS 8.5.5 gives 415 Media unsupported Status with response header Accept →application/octet-stream, text/plain, application/xml, text/xml, application/x-www-form-urlencoded, application/*+xml, multipart/form-data, /


Accept →application/x-www-form-urlencoded


How to get pass this error and how to set response header for getting application/json with json response

Gold Win
  • 7
  • 1
  • 7

1 Answers1

0

Your issue should be resolved with the next issue of the Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported for @RequestBody answer.

Where necessary to remove annotation @RequestBody

Douglas Ribeiro
  • 2,867
  • 1
  • 18
  • 12