title: How to send multipart/form-data to ASP.NET Core Web API?
body: <p>I'm trying to send a image and text fields to an API endpoint but I'm received</p>
  <blockquote>
  <p>Unsupported content type 'multipart/form-data;
  boundary=---------------------------81801171514357</p>
  </blockquote>
  <p>This is a ASP.NET Core 2.1 Web API. I have this:</p>
  <pre><code>[HttpPost(&quot;/api/account&quot;), Authorize]
  public void SaveUser(UserModel info)
  </code></pre>
  <p>And my model:</p>
  <pre><code>    [JsonProperty(PropertyName = &quot;avatar&quot;)]
      [DataType(DataType.Upload)]
      public IFormFile Avatar { get; set; }
  
      [JsonProperty(PropertyName = &quot;name&quot;)]
      [DataType(DataType.Text)]
      public string Name { get; set; }
  </code></pre>
  <p>Then I use <a href="https://github.com/axios/axios" rel="noreferrer">axios</a>:</p>
  <pre><code>    var formData = new FormData();
      formData.append(&quot;avatar&quot;, imageFile);
      formData.append(&quot;name&quot;, name);
      axios.post(&quot;/api/account&quot;, formData);
  </code></pre>
  <p>I expected this method to run, not throw an exception. But how? I have tried to add:</p>
  <pre><code>[Consumes(&quot;application/json&quot;, &quot;multipart/form-data&quot;)]
  </code></pre>
  <p>But no success.</p>
  <p>Then I tried:</p>
  <pre><code>[HttpPost(&quot;/api/account&quot;), Authorize]
  public void SaveUser([FromForm]UserModel info)
  </code></pre>
  <p>The method runs, but the properties is empty on info object :(</p>
  <p><strong>UPDATE:</strong>
  Solution, don't use JsonProperty PropertyName. Use the variable name.</p>