Hi i am using Rest client i.e Postman to send the REST request but getting 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 is :
@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 the request as shown in picture via REST client.

Fixing 415 Unsupported Media Type errorsEnsure that you are sending the proper Content-Type header value. Verify that your server is able to process the value defined in the Content-Type header. Check the Accept header to verify what the server is actually willing to process.
You need to set the content-type in postman as JSON (application/json). Go to the body inside your POST request, there you will find the raw option. Right next to it, there will be a drop down, select JSON (application. json).
The 415 Unsupported Media Type error code usually indicates that the request entity has a media type that the server or resource does not support. The best way to fix the error is to make sure that you are sending the right Content-Type header value.
Change your Content-Type in Postman to application/json. Click on the Headers button to do so.
Also you are not producing json in the method. Remove the produces="application/json" from the annotation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With