Here are the curl commands for testing the FastAPI endpoints for your notes application. You can use these commands to perform CRUD operations via HTTP requests:
POST Request:
curl -X POST "http://localhost:8000/notes/" \
-H "Content-Type: application/json" \
-d '{"title": "Test Note", "content": "This is a test note"}'GET Request:
curl -X GET "http://localhost:8000/notes/"GET Request:
Replace {note_id} with the ID of the note you want to read.
curl -X GET "http://localhost:8000/notes/{note_id}"PUT Request:
Replace {note_id} with the ID of the note you want to update.
curl -X PUT "http://localhost:8000/notes/{note_id}" \
-H "Content-Type: application/json" \
-d '{"title": "Updated Note", "content": "Updated content"}'DELETE Request:
Replace {note_id} with the ID of the note you want to delete.
curl -X DELETE "http://localhost:8000/notes/{note_id}"-
Create a Note:
-X POST: Specifies the HTTP method (POST).-H "Content-Type: application/json": Sets the content type of the request to JSON.-d '{"title": "Test Note", "content": "This is a test note"}': Provides the data for the note to be created.
-
Read All Notes:
-X GET: Specifies the HTTP method (GET). No additional data is needed for this request.
-
Read a Specific Note by ID:
- Replace
{note_id}with the actual ID of the note you want to retrieve. This fetches a specific note by its ID.
- Replace
-
Update a Note:
-X PUT: Specifies the HTTP method (PUT).-H "Content-Type: application/json": Sets the content type to JSON.-d '{"title": "Updated Note", "content": "Updated content"}': Provides the updated data for the note.
-
Delete a Note:
-X DELETE: Specifies the HTTP method (DELETE). No additional data is needed for this request.
Replace http://localhost:8000 with the appropriate URL if your FastAPI application is running on a different host or port.