< Stacks & Concept Used >
- Apache-Netbeans
- Postman API
- Spring-Boot Framework
- Java List Interface (implemented by ArrayList Class)
- Java Map Interface (implemented by HashMap Class)
Code Description is as below...
< GET Method >
- Description: Get all Countries List
- Request URL: http://localhost:8080/getcountries
- Request Body: N/A
- Response from Tomcat Server:
[{
"id": 1,
"countryName": "Korea",
"countryCapital": "Seoul"
},
{
"id": 2,
"countryName": "Ireland",
"countryCapital": "Dublin"
},
{
"id": 3,
"countryName": "Egpyt",
"countryCapital": "Cairo"
}]
< POST Method >
- Description: Add new Country Info with new index automatically added
- Request URL: http://localhost:8080/addcountry
- Request Body:
{
"countryName": "Japan",
"countryCapital": "Tokyo"
} - Response from Tomcat Server:
{
"id": 4,
"countryName": "Japan",
"countryCapital": "Tokyo"
}
< PUT Method >
- Description: Update Country Info at specific Index
- Request URL: http://localhost:8080/updatecountry
- Request Body:
{
"id": 4,
"countryName": "India",
"countryCapital": "Delhi"
} - Response from Tomcat Server: Updated from Japan (old info) → India (updated Info)
{
"id": 4,
"countryName": "India",
"countryCapital": "Delhi"
}
< DELETE Method >
- Description: Delete Country Info at specific Index
- Request URL: http://localhost:8080/deletecountry/4
- Request Body: N/A
- Response from Tomcat Server:
{
"msg": "Country Deleted",
"id": 4
}