Sending File and Data to a Minimal API endpoint
Hi. I am using .NET 7, Minimal API and Mailkit.
What I want to do is to send an attachment along with other information in an email. I want to receive both the information and the file using a Form-Data request type but I am having problems receiving the information .
The error I am getting is:
.
Here is the endpoint code :
And here is the REmailWithAttachments class:
5 Replies
Bit of a stab in the dark, but could it be because of the constructor?
Either delete it since it's not needed, or add a default constructor
I tried that but still the same problem 😢
Oh, it looks like they are still working on it:
https://github.com/dotnet/aspnetcore/issues/39430
GitHub
Support Form binding for Minimal endpoints · Issue #39430 · dotnet/...
Support for simple types. ##44653 Suport for complext types. Support for IFormCollection
Ah, another reason to not use minimal APIs then
Had to learn it the hard way