1

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?

2
  • What do you mean I need to know what the LicenseFileType is? You don't know what's the enum type or how to pass the value? Commented Feb 23, 2022 at 6:50
  • I really don't know how to pass the values. But @XinranShen is answer below has the solution. Thanks! Commented Feb 23, 2022 at 10:19

1 Answer 1

2

Swagger does not support the transmission of this format by default, So I suggest you use postman to send requset.

enter image description here

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot! I didn't kwow that the solution is pass files in array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.