I am working on a Web API project and I'm unable to post both model and file simultaneously at a time. Postman throws an exception:
System.Net.Http.UnsupportedMediaTypeException"
How can I fix this problem?
My code is looking like:
[HttpPost]
[Route("Appeal")]
public IHttpActionResult SaveAppeal(AppealModel model)
{
try
{
var file = HttpContext.Current.Request.Files.Count > 0 ?
HttpContext.Current.Request.Files[0] : null;
var AppealResponses = _ContactService.SaveAppeals(model);
return Ok(new { AppealResponses });
}
catch (Exception ex)
{
_log.ErrorFormat("Error in AppealResponses. Error:{0}", ex.Message);
_log.Error(ex);
throw;
}
}