I am trying to post a file from Postman to the endpoint I have created. but it gives me this error. I am not passing the header Content-Type in postman
415 Unsupported Media Type
[Consumes("multipart/form-data")]
[HttpPost]
public async Task<IActionResult> SendEmail([FromBody]Entity entity)
{
try
{
return OK();
}
catch (Exception e)
{
throw e;
}
}
public class Entity
{
public List<IFormFile> Files { get; set; }
}
Try using [FromForm]
instead of [FromBody]
for the method parameter if you're POSTing form data.