0
Hello, I’m trying to make a registration of a game but when I try to run by Postman it does not work and says that everything is null
Code
[HttpPost]
public async Task<IActionResult> CriarJogo([FromBody] Jogos jogo)
{
_contexto.Add(jogo);
await _contexto.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
Postman
{
"Jogo":{
"JogoNome": "Forza Horizon",
"JogoDescricao": "Jogo de corrida realista.",
"DataLancamento": "23/10/2012"
}
}
Model
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int JogoId { get; set; }
[Required]
[Column(TypeName = "varchar(100)")]
public string JogoNome { get; set; }
[Required]
[Column(TypeName = "text")]
public string JogoDescricao { get; set; }
[Required]
[Column(TypeName = "Date")]
public DateTime DataLancamento { get; set; }
The values remain null
– Leonardo Rocha
Can you complement the answer with the request you’re making on Postman? You may be forgetting some detail
– M. Bertolazo
I just redo my controller and it worked
– Leonardo Rocha
I don’t know exactly what the problem was, it just worked
– Leonardo Rocha
@Leonardorocha cool Leonardo, if my answer helped you, please mark it as the correct one so that the question is finalized.
– M. Bertolazo