Aspnetcore.docs: 400 "The input was not valid." on POST request

Created on 15 Dec 2018  Â·  3Comments  Â·  Source: dotnet/AspNetCore.Docs

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);
        }
...

Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

P4 Source - Docs.ms

Most helpful comment

Found the issue. It's important to have Content-Type header set to application/json in Postman.

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings