java - How to send JSON object to rest webservice? -


i have rest webservice @ http://localhost:8600/rest/student/details update details of student database. have send details json format in method post.

the below method generate json message

private void createorupdatestudent(webresource service) {     gson gson = new gson();      studentimpl student= new studentimpl ();      student.setid(6);     student.setname("godwin");     student.setsex("male");           studentview view = new studentview(student);              system.out.println("::::::"+service.path("/rest/student").path("/details").type("application/json").post(clientresponse.class, gson.tojson(view))); } 

where studentview class below.

@xmlrootelement(name="clusterzipcode") public class studentview {        public integer id;     public string name;     public string sex;      public studentview() {}     public studentview(studentimpl  student) {         this.id = student.getid();         this.name = student.getname();         this.sex = student.getsex();     } 

while sending above getting error stating cause: com.mysql.jdbc.exceptions.jdbc4.mysqlintegrityconstraintviolationexception: column 'name' cannot null

is passing json values correctly or if there alternate method send json message please suggest me.

i cannot see on post doing call database. can see creating student , then, there, creating view (assuming method being called). error getting related fact that, @ point, calling database enter new row in (probably) student model. if have got hibernate, can make sure not calling .save or .update @ point between call student , before call setname?


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -