I have read a lot of questions regarding similar issues, but none of them seems to work for me.
I am receiving null for the movie object in the post action method.
This is my controller:
public class MovieController : Controller
{
[Route("movies/all")]
[HttpGet]
public ActionResult All()
{
List<string> movies = new List<string>();
movies.Add("Some Movie");
movies.Add("Diamond Team");
//Get movies
return Ok(movies);
}
[Route("movies/post")]
[HttpPost]
public ActionResult Post([FromBody] Movie movie)
{
Console.WriteLine(movie);
List<string> movies = new List<string>();
movies.Add(movie.title);
//Get movies
return Ok(movies);
}
public ActionResult Index()
{
return View();
}
}
This is the Movies class:
public class Movie
{
public string title { get; set; }
public float rating { get; set; }
public int year { get; set; }
public Movie(string title,float rating, int year)
{
this.title = title;
this.rating = rating;
this.year = year;
}
public Movie()
{
}
}
This is the post request (using postman), I have tried either application/json and application/json; charset=utf-8 as the Content-Type but in both cases I have received null for the movie object:
{
"title":"Some Movie",
"rating":"1.87",
"year":"2011"
}
How can I fix this?


