How to post file with the list of Class in C#

API built in dotnet core and for file Upload I use IFormFile

When I post file in backend but file not post. I try different way but not success.

My C# model like as below.

public class SaveDisputeViewModel
    public string DisputeDescription { get; set; }
    public List<SaveAttachment> Attachments { get; set; }

public class SaveAttachment
    public string AttachCode { get; set; }
    public IFormFile File { get; set; }

Using postman, I try different way but doesn’t work. Attachments show me always null.

Have you tried only with the Key Attachments, instead of Attachments[0]File?

Yes, I tried but doesn’t work.