title: Multipart/form-data images upload with JSON asp.net core api
body: <p>How to POST both images and JSON at the same time in a single POST ? (using multipart)
  I have a form with some data that i put into JSON and the users can add 0 to 6 photos and submit it to the API.</p>
  
  <p>Can someone explain me how to do it ?</p>
  
  <p>Edit :
  Here is my code thanks to your help :</p>
  
  <pre><code>    // POST api/&lt;controller&gt;
      [HttpPost, Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
      public IActionResult Post(ViewModel vm)
      {
          IActionResult response = Unauthorized();
  
          var data = vm.FamilleProduit;
          var reforigine = vm.RefOrigine;
  
          if (vm.Images != null)
          {
              foreach (var image in vm.Images)
              {
                  byte[] fileData = null;
  
                  // read file to byte array
                  using (var binaryReader = new BinaryReader(image.OpenReadStream()))
                  {
                      fileData = binaryReader.ReadBytes((int)image.Length);
                  }
              }
          }
          return response;
      }
  
      public class ViewModel
      {
          public string FamilleProduit { get; set; }
          public string RefOrigine { get; set; }
          public List&lt;IFormFile&gt; Images { get; set; }
      }
  </code></pre>
  
  <p>I'm testing with Postman and i POST 2 text (FamilleProduit &amp; RefOrigine) and 2 files (2 images) with "multipart/form-data".
  I get the 2 texts perfectly but Images field is null everytime.</p>
  
  <p>Thanks,
  Tristan.</p>