From the course: Creating Spring Boot Microservices

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Create the RestController HTTP POST endpoint

Create the RestController HTTP POST endpoint - Spring Boot Tutorial

From the course: Creating Spring Boot Microservices

Create the RestController HTTP POST endpoint

- [Instructor] Now let's implement an API to create a tour rating. But do we want all the attributes of a tour rating to be sent in the request body? Let's look at the tour rating. So here is our tour rating entity. We have the generated ID, a tour, object, customer ID, score, and comment. So the ID for creating will not be passed in. That's going to be generated. The customer ID and the score and the comment, I think that's fine to put in the payload. But I don't think we want to have the client send an entire tour as part of the request body. They would likely just send a tour identifier. So we would like to create a transfer object, a data transfer object, to encapsulate the request body. And that's what I've done in rating DTO in the web folder. So in the web folder, which I've created, there's the rating DTO, and we're in the branch 0503B. And so, here we have the rating DTO and the attributes are score, a comment, and a customer ID and we don't have a tour ID here because that's…

Contents