Question: Multipart form-data with Refit
Hi,
I have a dotnet core web api endpoint that takes a strongly typed object as argument
public class FileUploadArgs
{
public int Id { get; set; }
public string Email { get; set; }
public IFormFileCollection Files { get; set; }
}
Endpoint signature:
[HttpPost, Route("upload")]
public async Task<IActionResult> UploadFile([FromForm] FileUploadArgs args)
I call this method via HTTPIE on shell as
$ http -f POST localhost:5000/api/v3/file/upload Id='123456' Email='[email protected]' 'Files'@/mnt/c/apiloadtest/2124545.pdf x-api-key:'{my-api-key}'
I want to write this endpoint in Refit interface in another app that will send files to this endpoint along with other form data.
I'm not sure how this can be be written in Refit. Any help would be appreciated!
Thanks!
I had just one file to send but I sent it this way:
[Multipart] [Post("your route")] Task Populate([AliasAs("parametername")] byte[] your file);
Hi I also encountered this problem, how do you solve this problem
Help the baby. The baby's crying
Hi I also encountered this problem, how do you solve this problem
send files as byte array or base64 string
But it lost its original meaning And then there's no way to get the file information across
you have a second option to wait when refit devs add this feature. They didn't it for a 2 years FYI))
Mm-hmm. Ooooooo the baby is already crying

I successfully fulfilled the requirement
While multipart works, sending form-data in the request is not supported. The content-type is always a JSON internally. Any workaround this?
I'm also struggling with this under https://github.com/OrchardCMS/OrchardCore/issues/16430. I couldn't find a way to send a request with Refit to the below API endpoint:
[HttpPost]
[Route("setup")]
public async Task<ActionResult> Setup(SetupApiViewModel model, IFormFile recipe = null)