Build Spring Boot REST API | GET and POST Methods | Chapter #3

Published: 17 March 2022
on channel: Genuine Coder
12,808
148

In this tutorial, we will learn how to create REST API using spring boot. We will create two endpoints. One GET endpoint for getting all the employee objects from the server and one POST endpoint for accepting new employees that need to be saved.

For marking a class as a REST Controller, spring provides an annotation "@RestController". Then we can write functions in the class that creates new Restful API endpoints.

For creating a GET endpoint, we will use @GetMapping annotation. Within the annotation, we will give the URL we would like to have for the endpoint. Similarly, for creating a POST endpoint, we will use @PostMapping annotation.

Once the endpoints are created, we will test them using the Postman tool.

You can find this project in GitHub at https://github.com/afsalashyana/Sprin...
Genuine Coder Blog: https://www.genuinecoder.com/

Tags: #Java #SpringBoot

Introduction: (0:00)
Create new Rest Controller class: (1:33)
Create GET endpoint: (4:04)
Test GET endpoint with Postman: (8:55)
Create POST endpoint: (11:46)
Test POST endpoint with Postman: (14:00)
Improve POST endpoint by returning Employee object: (17:34)


Watch video Build Spring Boot REST API | GET and POST Methods | Chapter #3 online without registration, duration hours minute second in high quality. This video was added by user Genuine Coder 17 March 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 12,80 once and liked it 14 people.