Hi,
I have @RestController with class UserController which has below method in it as eg
@RequestMapping(value = "/addUser", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public String generateUser(@RequestBody User user) { userService.create(user); return "Done"; }
Here User is my Entity with firstName and lastName columns.
Problem is how to send data to this user entity from postman in json format.
I tried sending through postman as below
{ "firstName": "NewFirst", "lastName": "NewLast" }
and getting error in postman as below { "status": 415, "error": "Unsupported Media Type", "exception": "org.springframework.web.HttpMediaTypeNotSupportedException", "message": "Content type 'application/json;charset=UTF-8' not supported", "path": "/addUser" }
How to resolve it? ie how to Assign json to JPA Entity
Thanks.
|