Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

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:

1. Create a Note

POST Request:

curl -X POST "http://localhost:8000/notes/" \
-H "Content-Type: application/json" \
-d '{"title": "Test Note", "content": "This is a test note"}'

2. Read All Notes

GET Request:

curl -X GET "http://localhost:8000/notes/"

3. Read a Specific Note by ID

GET Request:

Replace {note_id} with the ID of the note you want to read.

curl -X GET "http://localhost:8000/notes/{note_id}"

4. Update a Note

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"}'

5. Delete a Note

DELETE Request:

Replace {note_id} with the ID of the note you want to delete.

curl -X DELETE "http://localhost:8000/notes/{note_id}"

Explanation of Each Command

  1. 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.
  2. Read All Notes:

    • -X GET: Specifies the HTTP method (GET). No additional data is needed for this request.
  3. 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.
  4. 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.
  5. 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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages