The Showroom REST API creates brands and adds products to those brands.
Isaiah Jenkins
- Java (Server-side language)
- Hibernate (ORM)
- MySQL (Server)
- MySQL Workbench (visual database design tool for MySQL database)
- Jersey (JAX-RS)
- Tomcat (Web server)
- Postman (REST Client)
- Maven (Dependency Injection)
- Eclispe (IDE, Jave EE version 2020-12)
Note: Make sure to start your MySQL server on your computer.
Schema - showroom
Tables - brands, products
In the products table, set up a foreign key for brand id referenced to the brands table in showroom schema. Each product is tagged to a brand with the brand's id.
- Open Eclipse.
- Right-click on "restapi" project folder.
- Click Run As -> Run on Server.
- Make sure the web server is the latest Tomcat for v9.x.x.
- Hit Finish.
Important: Make sure the Content-type header is set to application/json for the requests except for DELETE operation.
Ex:
POST http://localhost:8080/restapp/showroom/brands
In BODY, send raw JSON object like below
{
"brandName": "my brand"
}
Ex:
GET http://localhost:8080/restapp/showroom/brands
No body
Ex:
GET http://localhost:8080/restapp/showroom/brands/4
No body
Ex:
GET http://localhost:8080/restapp/showroom/brands/4/products
No body
Ex:
GET http://localhost:8080/restapp/showroom/brands/4/products?category=clothing
No body
Ex:
PUT http://localhost:8080/restapp/showroom/brands/16
In BODY, send raw JSON object like below
{
"brandId": 16,
"brandName": "brand18"
}
Ex:
DELETE http://localhost:8080/restapp/showroom/brands/16
No body