Clone and open the project in your IDE. Run the main class ProductApplication as spring boot application. On startup spring boot will read the data.sql file and execute the contents.
The Product Service is now ready to receive API requests.
Find All Products
Send a GET
Request to http://localhost:8080/products
Find a Product with Id 1
Send a GET
Request to http://localhost:8080/products/1
Add New Product
Send a POST
request to http://localhost:8080/products
Sample Request Body
{
"productId": "LEVIS12345",
"title": "Jeans",
"description": "Regular fit jeans",
"brand": "LEVIS",
"price": 12000.00,
"color": "Black"
}
Update a Product with Id 1
Send a PATCH
request to http://localhost:8080/products/1
Sample Request Body
{
"price": 20000.00,
"color": "BLUE"
}
Response
{
"id": 1,
"productId": "LEVIS12345",
"title": "Jeans",
"description": "Regular fit jeans",
"brand": "LEVIS",
"price": 20000.00,
"color": "BLUE"
}
Delete a Product with Id 1
Send a DELETE
request to http://localhost:8080/products/1
Since the DELETE
operation is idempotent
, it will return a 204 when the resource is deleted, or it does not exist.