This is my controller action:
// POST: api/Customers/Create
[HttpPost(), Route("Create")]
public async Task<ActionResult> CreateAsync([FromForm] CustomerModel model)
And it receives a CustomerModel
:
public Guid? Id { get; set; }
public string Name { get; set; }
public string Address { get; set; }
public string PhoneNumber { get; set; }
public string Email { get; set; }
public bool? IsActive { get; set; }
public List<CustomerLicenseModel> LicenseFiles { get; set; }
My CustomerModel
has a custom class that is a list of files of type CustomerLicenseModel
public List<CustomerLicenseModel> LicenseFiles { get; set; }
And this is the CustomerLicenseModel
:
public class CustomerLicenseModel
{
public LicenseFileType LicenseFileType { get; set; }
public IFormFile LicenseFile { get; set; }
}
LicenseFileType
can be Front or Back.
public enum LicenseFileType
{
Front,
Back
}
How can I send this via a http request?
If I have a List<IFormFile>
inside my CustomerModel
, I can send multiple files via postman or swagger for an example, but I need to know what the LicenseFileType
is.
Can somebody help?
CodePudding user response:
Swagger
does not support the transmission of this format by default, So I suggest you use postman to send requset.