When uploading IFormFile file with minimalAPI in swagger, the file is null

209 Views Asked by At

I'm trying to write a http post using minimal API in C# NetCore7, that recieves IFormFile file.

MinimalAPI:

 var group = app.MapGroup("Payment").WithTags("Payment").WithOpenApi();
group.MapPost("htmlToPdf", async (IFormFile file) =>
    {
       ....
       ...       
}).Accepts<IFormFile>("multipart/form-data");

When I upload the file by using swaggerUI, the file is null:

SwaggerUI

What am I doing wrong?

1

There are 1 best solutions below

1
On BEST ANSWER

The problem was in the following line:

var group = app.MapGroup("Payment").WithTags("Payment").WithOpenApi();

When i removed the following WithOpenAPi() extension, The uploading file is work properlly!