I have a Controller that can receive Post requests.
public IHttpActionResult PostCreaAlimento([FromBody] Alimento alimento)
{
if (!ModelState.IsValid)
return BadRequest("Invalid data.");
return _repositorio.CreaAlimento(alimento) ? Ok(alimento) : (IHttpActionResult)NotFound();
}
The request is correctly done on swagger, and I receive a response code 200.
But, if I try to do the same on POSTMAN, I receive an Unsupported Media File.
CodePudding user response:
You pass json data as form data but your controller accepts request body data as raw data. You should change body type as raw data.