From the course: Creating Your First Spring Boot Microservice
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Create RestController HTTP POST method
From the course: Creating Your First Spring Boot Microservice
Create RestController HTTP POST method
- [Instructor] Now let's implement an API to create a TourRating. But can all the attributes of a TourRating be sent in the request body? Well, let's look at TourRating. We have a integer score and a string comment, yeah that's fine sending on a HTTP payload. Let's look at TourRatingPk. Ah, so we have a tour, which is a type tour and a customer ID, which is integer. Customer ID is fine but I don't think a client would want to send an entire tour as part of the request body, they would likely just use a tour identifier. So we should create a data transfer object to encapsulate the request body. And that's what I've done in RatingDto. So in this web packet I have RatingDto and the attributes are score, a comment, and a customer ID. We don't have a tour ID in here. And that's because that's going to be a parameter on the URL. So we can apply Java validations here. The minimum score is zero, the maximum score is five.…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Choosing the right framework3m 26s
-
(Locked)
Declaring a new RestController3m 6s
-
(Locked)
Create RestController HTTP POST method8m 2s
-
(Locked)
Create RestController HTTP GET methods4m 48s
-
(Locked)
Create RestController HTTP PUT, PATCH, and DELETE methods6m 54s
-
(Locked)
Paging and sorting DTOs5m 1s
-
(Locked)
-
-