title: How to pass object from React.js to Controller API?
body: <p>I am a novice in ASP.NET and try to write my first application, whose client-size which is written in React.js, using this technology . This is the simple SPA, which should send the data from its form and getting response. But every request ends up with the message (&quot;<strong>Request failed with status code 415</strong>&quot;) and I can't resolve this problem.</p>
  <p>FormComponent.js code:</p>
  <pre><code>import './Form.css'
  import React, { Component } from 'react'
  import axios from 'axios'
  
  export default class Form extends Component {
      
      constructor(props){
          super(props)
  
          this.state={
              name: &quot;&quot;,
              email: &quot;&quot;,
              text: &quot;&quot;
          }
  
          this.onNameChange = this.onNameChange.bind(this);
          this.onEmailChange = this.onEmailChange.bind(this);
          this.onTextChange = this.onTextChange.bind(this);
          this.onSubmit = this.onSubmit.bind(this);
      }
  
      onNameChange(e) {
          this.setState({ name: e.target.value });
      }
  
      onEmailChange(e) {
          this.setState({ email: e.target.value });
      }
  
      onTextChange(e) {
          this.setState({ text: e.target.value });
      }
  
      onSubmit(e) {
          e.preventDefault();
          var commentName = this.state.name;
          var commentEmail = this.state.email;
          var commentText = this.state.text;
          if (!commentName || !commentEmail || !commentText) {
              return;
          }
  
          console.log(commentName);
          console.log(commentEmail);
          console.log(commentText);
  
          var data = new FormData();
  
          data.append(&quot;Name&quot;, commentName);
          data.append(&quot;Email&quot;, commentEmail);
          data.append(&quot;Text&quot;, commentText);
          axios({
              method: 'post',
              url: '/api/Comment',
              data: data,
          })
              .then((res) =&gt; {
                  console.log(res.data);
              })
              .catch((err) =&gt; { throw err });
  
          this.setState({ name: &quot;&quot;, email: &quot;&quot;, text: &quot;&quot; });
          
      }
  
      render() {
          return (
              &lt;section&gt;
                  &lt;form id=&quot;my-form&quot; onSubmit={this.onSubmit}&gt;
                      &lt;a id=&quot;feedback-btn&quot; type=&quot;submit&quot;&gt;Нам важлива ваша думка&lt;/a&gt;
                      &lt;label htmlFor=&quot;in_name&quot;&gt;Ім'я:&lt;/label&gt;
                      &lt;input id=&quot;in_name&quot; type=&quot;text&quot; onChange={this.onNameChange}/&gt;
                      &lt;label htmlFor=&quot;in_email&quot;&gt;Email:&lt;/label&gt;
                      &lt;input id=&quot;in_email&quot; type=&quot;email&quot; onChange={this.onEmailChange}&gt;&lt;/input&gt;
                      &lt;label htmlFor=&quot;text_feedback&quot;&gt;Коментар:&lt;/label&gt;
                      &lt;textarea name=&quot;feedback&quot; id=&quot;text_feedback&quot; onChange={this.onTextChange}&gt;&lt;/textarea&gt;
                      &lt;button type=&quot;submit&quot;&gt;Залиште відгук&lt;/button&gt;
                  &lt;/form&gt;
              &lt;/section&gt;
          )
      }
  }
  </code></pre>
  <p>Controller API Code:</p>
  <pre><code>using Gazda.Models;
  using Microsoft.AspNetCore.Mvc;
  using System;
  
  // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
  
  namespace Gazda.Controllers
  {
      [Route(&quot;/api/Comment&quot;)]
      [ApiController]
      public class CommentController : ControllerBase
      {
  
          [HttpPost]
          public IActionResult Post([FromBody]Comment comment)
          {
  
              comment.Id = Guid.NewGuid().ToString();
  
              return Ok(comment);
          }
  
          [HttpGet]
          public IActionResult Get()
          {
              return Ok(&quot;success&quot;);
          }
  
      }
  }
  </code></pre>
  <p>and Comment Model:</p>
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Threading.Tasks;
  
  namespace Gazda.Models
  {
      public class Comment
      {
          public string Id { get; set; }
          public string Name { get; set; }
          public string Email { get; set; }
          public string Text { get; set; }
      }
  }
  
  </code></pre>
  <p>It seems I pass arguments to my Controller API wrongly, but I spent few hours for it and couldn't find any solution.</p>
  <p>Thank you in advance!!!!</p>
  <p>P.S. Sorry for my English</p>