[ApiController]
[Route("[controller]/[action]")]
public class TestController
{
[HttpPost]
[Consumes("multipart/form-data")]
public void Post([FromForm] TestModel testModel)
{
}
}
public class TestModel
{
public IFormFile File { get; set; }
public string String { get; set; }
}
This code will not work, because it contains duplicate parameter, and if rename it then Refit library would throw System.ArgumentException: Multipart requests may not contain a Body parameter.
If split parameters from model, the code will work correctly:
After the line probably missing
continue
keyword.Considering following code:
Utility generates:
This code will not work, because it contains duplicate parameter, and if rename it then Refit library would throw
System.ArgumentException: Multipart requests may not contain a Body parameter
.If split parameters from model, the code will work correctly:
If Im understanding correctly, [FromForm] model should be splitted in separate parameters, if it contains IFormFile parameter.