REST API
03 August 2025 10:43
REST => Representational state transfer.
Note: REST APIs expose resource via http endpoints like
1. Get /products
2. Post /products
3. Get /product/{id} Model & View
4. PUT /product/{id}
5. DELETE /product/{id}
6. PATCH /product/{id}
Understanding HTTP status code:
200 OK -> Success(Get, Put, Delete)
201 Created -> Succes(POST)
204 No content -> success without response body
400 Bad Request -> client error ( invalid input) -> missing field, validation error
401 Untheorized -> Not Authenticated
403 Forbidden -> Authenticated but no access
404 Not found -> resource not found
500 Internal server error - > server-side bug
Project : Design Rest API for a boot resource.
--------------------------------------------------------------
Entity : Book
Book :
-id
-title
-author
-price
Define restful points
---------------------------
Operation Http Methods Url Des
Get all books GET /books Fetch list of all books: 200 ok
Get a book by ID GET /book{id} Fetch a single book : 200 OK, 404
Add new book POST /books Create new Book : 201 created, 404
[Link]/courses/
New Section 1 Page 1
Json to java object
response
New Section 1 Page 2