title: WebAPI method with file and body
body: <p>I have a WebAPI method as shown below. Uploading a file works just fine with that, but I also need an additional object with information on how to handle the file. What I have tried so far:</p>
  
  <pre><code>//Works fine but no body defined
  [HttpPut("{id}")]
  public IActionResult Put(string id, IFormFile file)
  {
      //Do stuff
      return StatusCode(200);
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public class UploadFile
  {
      //As simple example
      public string Description { get; set; }
      public Dictionary&lt;string, string&gt; Keys { get; set; }
  }
  
  //What I would like to have, but doesn't work
  [HttpPut("{id}")]
  public IActionResult PutTest(string id, IFormFile file, [FromBody] UploadFile info)
  {
      //Do stuff
      return StatusCode(200);
  }
  </code></pre>
  
  <p>using SwaggerUI with the following input:</p>
  
  <p><a href="https://i.stack.imgur.com/sGG2h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sGG2h.png" alt="enter image description here"></a></p>
  
  <p>I get a 400 Bad Request back with the message <code>"The input was not valid."</code>. SwaggerUI shows the following cURL for the request (which does not seem to contain any info on the body):</p>
  
  <pre><code>curl -X PUT "https://localhost:5001/api/Document/test/test.txt" -H  "accept: application/json" -H  "Content-Type: multipart/form-data" -d {"file":{}}
  </code></pre>
  
  <p>How can I best approach this to get the result I would like?</p>