English 中文(简体)
Spring Boot & H2 - REST APIs
  • 时间:2024-11-03

Spring Boot & H2 - REST APIs


Previous Page Next Page  

As in previous chapter Apppcation Setup, we ve created the required files in spring boot project. Now create the following collection in POSTMAN to test the REST APIs.

Postman Structure

    GET Get All Employees − A GET request to return all the employees.

    POST Add an Employee − A POST request to create an employee.

    PUT Update an Employee − A PUT request to update an existing employee.

    GET An Employee − A GET request to get an employee identified by its id.

    Delete An Employee − A Delete request to delete an employee identified by its id.

GET All Employees

Set the following parameters in POSTMAN.

    HTTP Method − GET

    URL − http://localhost:8080/emp/employees

Add an Employee

Set the following parameters in POSTMAN.

    HTTP Method − POST

    URL − http://localhost:8080/emp/employee

    BODY − An employee JSON


{  
   "id": "1",  
   "age": "35",  
   "name": "Jupe",  
   "email": "jupe@gmail.com"  
}   

Update an Employee

Set the following parameters in POSTMAN.

    HTTP Method − PUT

    URL − http://localhost:8080/emp/employee

    BODY − An employee JSON


{  
   "id": "1",  
   "age": "35",  
   "name": "Jupe",  
   "email": "jupe.roberts@gmail.com"  
}   

GET An Employees

Set the following parameters in POSTMAN.

    HTTP Method − GET

    URL - http://localhost:8080/emp/employee/1 − Where 1 is the employee id

Delete An Employees

Set the following parameters in POSTMAN.

    HTTP Method − DELETE

    URL - http://localhost:8080/emp/employee/1 − Where 1 is the employee id

Advertisements