title: How to make POST Request through react.js?
body: <p>I am trying to make POST request call through react,but i am getting error.If any body knows help me out and please assist me where i have to changes.</p>
  
  <p>Error is: {timestamp: 1510396949738, status: 415, error: "Unsupported Media exception: "org.springframework.web.HttpMediaTypeNotSupportedException", message: "Content type 'multipart/form-data;boundary=----Web…daryTY6125I1exH8Ry7f;charset=UTF-8' not supported", … …}</p>
  
  <p>Here my React code:</p>
  
  <pre><code>import React from 'react';
  import RaisedButton from 'material-ui/RaisedButton';
  import TextField from 'material-ui/TextField';
  const style = {
    margin: 15,
  marginLeft: 600
  };
  export default class  Register extends React.Component {
    constructor(props) {
      super(props);
      this.onSubmit=this.handleSubmit.bind(this);
  }
  handleSubmit(e) {
      e.preventDefault();
      var self = this;
  
  
      var data = new FormData();
      const payload = {
      id: self.refs.id.getValue(),
      studentName: self.refs.sname.getValue(),
      age: self.refs.age.getValue(),
      emailId: self.refs.emailId.getValue()
  };
  data.append("myjsonkey", JSON.stringify(payload));
  
  fetch('http://localhost:8083/students/', {
      method: 'POST',
      headers: {
      'Accept': 'application/json'
    },
      body: data
    })
      .then(function(response) {
          return response.json()
        }).then(function(body) {
          console.log(body);
        });
    }
  
  render() {
      return (
        &lt;form onSubmit={this.onSubmit}&gt;
        &lt;div style={style}&gt;
        &lt;TextField ref='id'
        hintText="Enter Student id"
        floatingLabelText="id"
        /&gt;
        &lt;br/&gt;
        &lt;TextField ref='sname'
        hintText="Enter your Last Name"
        floatingLabelText="StudentName"
        /&gt;
        &lt;br/&gt;
        &lt;TextField ref='age'
        hintText="Enter your Age"
        floatingLabelText="age"
        /&gt;
        &lt;br/&gt;
  
        &lt;TextField ref='emailId'
        hintText="Enter your Email"
        floatingLabelText="emailId"
        /&gt;
        &lt;br/&gt;
        &lt;br/&gt;
        &lt;input type="submit" /&gt;
  
  
        &lt;/div&gt;
            &lt;/form&gt;
  
  
      );
    }
  
  
  }
  </code></pre>