Getting invalid media type error

Hi, I am using Rest client ie Postman to send a REST request, but I get an error:

{ "timestamp": 1432829209385, "status": 415, "error": "Unsupported Media Type", "exception": "org.springframework.web.HttpMediaTypeNotSupportedException", "message": "Content type 'text/plain;charset=UTF-8' not supported", "path": "/api/v1/user" } 

My controller:

 @RequestMapping(value = "/user", method = RequestMethod.PUT, produces = "application/json") public Map<String,Object> updateUser(@RequestBody @Valid User user) { // userService.updateUser(user); return ResponseHandler.generateResponse("", HttpStatus.ACCEPTED, false, null); } 

I am sending a request as shown in the picture through the REST client.

enter image description here

+7
json rest spring-boot
source share
1 answer

Change the Content-Type in Postman to application/json . Click the Headers button to do this.

Also you do not create json in the method. Remove produces="application/json" from the annotation

+25
source share

All Articles