title: How to send FormData from javascript to ASP.NET Core 2.1 web API using fetch
body: <p>i'm trying to create a form that sends FormData object to API controller that serializes the data to Article class, but i cannot get it to work. I have already tried the things that are commented.</p>
  
  <p>this is my HTML:</p>
  
  <pre><code>&lt;form onsubmit="postArticle()"&gt;
  &lt;input type="type" name="Title" value="" /&gt;
  &lt;input type="type" name="Content" value="" /&gt;
  &lt;input type="submit" value="Submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>this is my JS:</p>
  
  <pre><code>&lt;script&gt;
  
  var postArticle = () =&gt; {
      event.preventDefault();
      var Article = new FormData(this.event.target);
      console.log([...Article]);
      fetch('/api/Articles', {
          headers: {
              'Content-Type': 'multipart/formdata',
              //'Content-Type': 'application/json'
          },
          method: "POST",
          body: Article
          //body: JSON.stringify(Article)
      })
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>Controller: </p>
  
  <pre><code>    // POST: api/Articles
      [HttpPost]
      public async Task&lt;IActionResult&gt; PostArticle(Article article)
      {
          string name = article.Title;
          if (!ModelState.IsValid)
          {
              return Ok();
          }
  
          _context.Article.Add(article);
          await _context.SaveChangesAsync();
  
          return Ok();
      }
  </code></pre>
  
  <p>and my Article class:</p>
  
  <pre><code>public class Article
  {
      public int Id { get; set; }
      public string Title { get; set; }
      public string Content { get; set; }
  }
  </code></pre>