Implementing POST Method to insert data in MYSQL database using RESTFul web service
<p>I am trying to implement POST method using restful web service using jersey and  Postman for rest client in java. Now I am unable to insert data into the database using post method. I have table in mysql database name person which has 3 fields. id(primary key,auto increment), firstname, lastname. I made there java classes one is person as model class and PersonResource class for declaring REST api and PersonService for implementing REST method to make crud operation.</p>

<pre><code>   PersonResource class is:

        @Path("/person")
        public class PersonResource {
            DbConnection connect=new DbConnection();
            Connection conn=null;

            PersonService service=new PersonService();

            @POST 
            @Consumes(MediaType.APPLICATION_JSON)// specifies the request body content
            @Produces(MediaType.APPLICATION_JSON)
            public Person addMessage(Person person) throws Exception{
            return service.addMessage(person);
        }
        }   
</code></pre>

<p>PersonService class is:</p>

<pre><code>        public class PersonService {

            DbConnection connect=new DbConnection();
            Connection conn=null;

            public Person addMessage(Person person) throws Exception {

            Person p=new Person();
            String sql="insert into person (firstname,lastname) values(?,?)";
            conn=connect.databaseConnection();
            PreparedStatement pst=conn.prepareStatement(sql);
                pst.setString(1,p.getFirstName());
                pst.setString(2,p.getLastName());   
                pst.executeUpdate();
                pst.close();
                return person;
        }
        }
</code></pre>

<p>I have successfully retrieve person info by person id. Now i want to make post request from postman to insert data in the mysql database.</p>

<p>From postman i made post request and select the content-type application/json in the header and write the data in the raw text in json format.when i hit the send button it getting 415 Unsupported Media Type. </p>

<p>can anybody help me how to capture the postman data to insert into the database or any help how to implement post method to insert record in database using REST from postman? Here is my postman window.
<a href="https://i.stack.imgur.com/zsZZn.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zsZZn.jpg" alt="enter image description here"></a>
    Thanks in advance</p>