-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: JPA Entity with Postman(Assign Json to JPA Entity)
PostPosted: Fri May 27, 2016 8:40 am 
Newbie

Joined: Sat May 21, 2016 4:56 am
Posts: 5
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.