Is it possible too upload files from a DTO with asp.net minimal api's ?
I've tried this:
public class MyDto
{
public string BlaBlaBla { get; set; }
public List<ListOfUselessStuff> MyList { get; set; }
public IFormFile MyFile { get; set; }
}
Endpoint
app.MapPost("MyRoute", DoStuff)
.WithTags("Tags")
.Accepts<MyDto>("multipart/form-data")
.Produces<NewlyCreatedDto>(200)
.ProducesValidationProblem(400)
.ProducesProblem(401)
.ProducesProblem(403)
.RequireAuthorization(Policies.RequireAdmin);
And finally Do Stuff:
private async Task<IResult> CreateQuestion([FromServices]IMediator mediator, [FromForm] MyDto dto)
{
//do stuff
}
But I just manage too get:
"Expected a supported JSON media type but got "multipart/form-data; boundary=---------------------------29663231333811935594178759367"."