Payload
{
"name":"walk dog",
"isComplete":true
}
TodoController.cs
...
[HttpPost]
public async Task<ActionResult<TodoItem>> Store(TodoItem todoItem)
{
_context.TodoItems.Add(todoItem);
await _context.SaveChangesAsync();
return CreatedAtAction("GetTodoItem", new { id = todoItem.Id }, todoItem);
}
...
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Can you debug to find out what you did wrong?
If you get a 405 Method Not Allowed error, it's probably the result of not compiling the project after adding the after adding the PostTodoItem method.
Found the issue. It's important to have Content-Type
header set to application/json
in Postman.
Most helpful comment
Found the issue. It's important to have
Content-Type
header set toapplication/json
in Postman.