Product REST API is an micorservice related to Product based REST appplication and implemeneted using Java Spring Boot for integarting with other systems/applications. This API has the following operations,
1. Create Product (POST /Products)
2. Get Products (GET /Products)
3. Get Product by ProductId (GET /Products/{productId})
4. Update Product (PUT /Products/{productId})
5. Delete Product (Delete /Products/{productId})
To create product in the system
POST /products
Headers
Parameter | Type | Description |
---|---|---|
authorization |
string |
Optional. authorization Credentials like Client Id and Client Secret |
X-Correlation-Id |
string |
Optional. 16 didgits UUID |
content-type |
string |
Required. Application/json |
Sample Request Body
{
"id": 1000,
"name": "Dell model 1",
"category": "Dell",
"status": "Active",
"price": 27000.0,
"quantity": 2
}
Sample Success Response
StatusCode as 200
Product Created Successfully
To retrieve all products from the system.
GET /products
Parameter | Type | Description |
---|---|---|
authorization |
string |
Optional. authorization Credentials like Client Id and Client Secret |
X-Correlation-Id |
string |
Optional. 16 didgits UUID |
Sample Response
Statuscode as 200
[
{
"id": 1000,
"name": "Dell model 1",
"category": "Dell",
"status": "Active",
"price": 27000.0,
"quantity": 2
},
{
"id": 1001,
"name": "Dell model 1",
"category": "Dell",
"status": "Active",
"price": 27000.0,
"quantity": 2
}
]
To retrive product details based on Product Id
GET /products/${productId}
Parameter | Type | Description |
---|---|---|
productId |
string |
Required. Product Id to fetch respective Product details |
Sample Response
Statuscode as 200
{
"id": 1000,
"name": "Dell model 1",
"category": "Dell",
"status": "Active",
"price": 27000.0,
"quantity": 2
}
Error Response If product Not Found
StatusCode as 404
{
"errorType": "404 NOT_FOUND",
"errorCode": "404",
"errorMessage": "Product Not Found"
}
To update product details based on Product Id
PUT /products/${productId}
Parameter | Type | Description |
---|---|---|
productId |
string |
Required. Product Id to fetch respective Product details |
Sample Request Body,
{
"name": "Iphone X",
"category": "Iphone",
"status": "Active",
"price": 37000.0,
"quantity": 5
}
Sample Response
Statuscode as 200
{
"id": 1000,
"name": "Iphone X",
"category": "Iphone",
"status": "Active",
"price": 37000.0,
"quantity": 5
}
Error Response If product Not Found
StatusCode as 404
{
"errorType": "404 NOT_FOUND",
"errorCode": "404",
"errorMessage": "Product Not Found"
}
To delete a product from the system based on Product Id
DELETE /products/${productId}
Parameter | Type | Description |
---|---|---|
productId |
string |
Required. Product Id to fetch respective Product details |
Sample Response
Statuscode as 200
Product deleted Successfully
Error Response If product Not Found
StatusCode as 404
{
"errorType": "404 NOT_FOUND",
"errorCode": "404",
"errorMessage": "Product Not Found"
}
Client: Java and Spring Boot Server: Tomcat
To complile this project run
gradle clean build
To deploy this project run
java -jar <snapshot-name>.jar
Beloe are the local run screenshots for reference
Create Product
Get Products
Get Product By Id
Get Product By Id if not found
Update Product by Id
Delete Product by Id