https://github.com/hr-fahim/spring-boot-restful-api-testing-with-postman-api
Building a RESTful API with Spring Boot and Testing with Postman: A Guide to Modern Web Development.
https://github.com/hr-fahim/spring-boot-restful-api-testing-with-postman-api
framework postman restful-api spring-boot
Last synced: about 1 month ago
JSON representation
Building a RESTful API with Spring Boot and Testing with Postman: A Guide to Modern Web Development.
- Host: GitHub
- URL: https://github.com/hr-fahim/spring-boot-restful-api-testing-with-postman-api
- Owner: HR-Fahim
- License: gpl-3.0
- Created: 2023-06-30T15:23:09.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-06-30T16:39:14.000Z (about 3 years ago)
- Last Synced: 2025-07-05T04:42:53.237Z (12 months ago)
- Topics: framework, postman, restful-api, spring-boot
- Homepage: https://hrfprofessional.medium.com/i-built-restful-api-with-spring-boot-tested-with-postman-2a821b75a89d
- Size: 114 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# About
This demonstrates how to build a simple RESTful API using the Spring Boot framework, display the user data on an HTML page, and test it
with Postman API.
## Prerequisites
Before starting this, make sure you have the following:
- Java Development Kit (JDK) installed
- Visual Studio Code (or any other IDE) installed
- Postman (or any other API testing tool) installed
## Getting Started
Follow the steps below to set up the project and run the application:
1. Clone the repository or download the project files.
2. Open the project in Visual Studio Code.
3. Open a terminal in Visual Studio Code (View -> Terminal).
4. Run the following command in the terminal to build and run the application:
```
./mvnw spring-boot:run
```
This will start the Spring Boot application and listen for requests on `http://localhost:8080`.
5. Open Postman and create a new request.
6. Set the request method to `GET` and enter the following URL:
```
http://localhost:8080/user
```
This will retrieve the user data from the API.
7. The response should contain the user's name and email.
8. Open a web browser and navigate to `http://localhost:8080/index.html`.

10. The HTML page will display the user's name and email obtained from the API.
## Project Structure
The project structure is as follows:
```
demo/
├── src/
│ └── main/
│ ├── java/
│ │ └── com/
│ │ └── example/
│ │ └── demo/
│ │ ├── controller/
│ │ │ └── UserController.java
│ │ └── DemoApplication.java
│ └── resources/
│ └── static/
│ └── index.html
└── pom.xml
```
- The `UserController` class in the `controller` package defines the API endpoint for retrieving user data.
- The `DemoApplication` class in the root package is the main entry point of the application.
- The `index.html` file in the `static` directory is the HTML page that displays the user data.
## Customize User Data
To customize the user data, follow these steps:
1. Open the `UserController` class (`src/main/java/com/example/demo/controller/UserController.java`).
2. Modify the `getUserInfo` method to return the desired user data. You can change the default values for the `name` and `email` parameters or fetch the data from a database or external service.
3. Rebuild and run the application to see the updated user data.
## API Testing
You can test the API endpoints using Postman or any other API testing tool.

## License
This project is licensed under the [GNU License](LICENSE).