Skip to content

Conversation

@tamnguyen976
Copy link

Summary

  • Added POST /posts endpoint in PostsController
  • Added server-side validation: returns 400 if title is blank
  • Uses in-memory list for dev mode (no database required)
  • Returns 201 Created with the new post's slug

Testing Steps

  1. Run backend:
    dotnet run --project MyFirstBlog
  2. In another terminal, create post:
    curl -X POST http://localhost:5000/posts
    -H "Content-Type: application/json"
    -d '{"title":"Hello","description":"World"}'
  3. Expected: 201 Created, JSON of new post
  4. Test with blank title:
    curl -X POST http://localhost:5000/posts
    -H "Content-Type: application/json"
    -d '{"title":"","description":"World"}'
    Expected: 400 Bad Request, "Title cannot be blank"

Notes

  • This PR completes backend part of assignment step 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant