Fondamentalmente sto cercando di caricare un'immagine con un enum utilizzando Web API 2.Come caricare il file e il modello usando l'API Web?
ecco la firma di controllo:
[HttpPost]
public UploadResponseVm Upload([FromBody]ResImageType type)
{
Il fatto è che ogni volta che provo ad inviare un modulo multistrato (con un file e un tipo) ottengo un errore 415:
{"Message":"The request entity's media type 'multipart/form-data' is not supported for this resource.","ExceptionMessage":"No MediaTypeFormatter is available to read an object of type 'ResImageType' from content with media type 'multipart/form-data'.","ExceptionType":"System.Net.Http.UnsupportedMediaTypeException","StackTrace":" at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, Type type, IEnumerable
1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)\r\n at System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable
1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)"}
ho anche aggiunto quanto segue alla mia classe startup.cs:
config.Formatters.Insert(0, new System.Net.Http.Formatting.JsonMediaTypeFormatter());
Come posso caricare un modello insieme a un file utilizzando un controller web api?