CRUD Operations on Products
-
Add Default Products (GET)
URL:http://localhost:8080/api/products/addDefault
-
Add New Product (POST)
URL:http://localhost:8080/api/products
Body:{ "id": 0, "name": "String", "cost": 0.0, "category": { "categoryId": 0, "categoryName": "String", "categoryDescription": "String", "products": [] } }
-
Add New Product (POST)
URL:http://localhost:8080/api/products
Body:{ "id": 0, "name": "Product Name", "cost": 0.0, "category": { "categoryId": 0, "categoryName": "Category Name", "categoryDescription": "Category Description", "products": [] } }
or
{ "id": 0, "name": "Product Name", "cost": 1542.0, "category": { "categoryId": 1 } }
Note: category id is mandatory
-
Get Product by Id (GET)
URL:http://localhost:8080/api/products/{id}
Body:{ "id": 0 }
-
Get All Products (GET)
a. URL:http://localhost:8080/api/products
Description: Using this you will get first 5 products
b. URL:http://localhost:8080/api/products?page=0
Description: Using this you will get 5 products of page 0 and you can change page likehttp://localhost:8080/api/products?page=1
c. URL:http://localhost:8080/api/categories?page=0&size=5
Description: Using this you will get 5 products of page 0 with default page size 5 and you can change page and size likehttp://localhost:8080/api/products?page=1&size=10
and you will get page 1 and 10 products will be displayed -
Delete Product by Id (DELETE)
URL:http://localhost:8080/api/products/{id}
Body:{ "id": 0 }
-
Update Product by Id (PUT)
URL:http://localhost:8080/api/products/{id}
Body:{ "id": 0, "name": "String", "cost": 0.0, "category": { "categoryId": 0, "categoryName": "String", "categoryDescription": "String", "products": [] } }