Problem is, I have an API that concatenates pdfs from Urls, and it's working in .NET 5 , but when starting to migrate to .NET 6, the use of IEnumerable<> , IFormFile, and IFormFileCollection , simply only accepts requests application/json.
Here is the endpoint in .NET 5 (Working)
[HttpPost]
public async Task<IActionResult> ConcatenarPdfsByUrl([FromForm] IEnumerable<string> urls)
{
var output = await TransformaPdfCore.PdfConcatenation(urls);
return File(output, "application/octet-stream");
}
result: Imagem 1 (.net 5)
And so is Endpoint in Minimal .net6
app.MapPost("/ConcatenaPdfsByUrl", async Task<IResult> (IEnumerable<string> urls, TransformaPdfCore transforma) =>
{
{
var output = await transforma.PdfConcatenation(urls);
return Results.File(output, "application/octet-stream");
}
}).Accepts<IEnumerable<string>>("multipart/form-data");
But the result is this: Imagem 2 (.net 6)
The question is, why does IEnumerable not have the same behavior? and if there is any solution, for example using IOperationFilter, so that I can make it work.
The IFormFileCollection Interface had the same problem