Spring Boot Bootcamp – Workbooks and Challenges
)}

Workbook 9.2

The grade-submission API will serve as a mediator between a consumer and the resources in an SQL database.

Screen Shot 2022-07-21 at 6.49.32 PM.png

Workbook 9.2 will prepare the REST endpoints for the GradeController.

Screen Shot 2022-07-21 at 6.55.45 PM.png

Intermission

Workbooks 9.2 and 9.3 are the same as 9.1.

  • If you don't need to further practice REST, skip them.

  • Otherwise, feel free to solve them.

The completed project can be found here:

Screen Shot 2022-09-26 at 7.53.27 PM.png A Postman collection will be provided in the lesson: "Saving a Student"

GET Request

  • method handles GET requests made on /grade/student/{studentId}/course/{courseId}.
  • return type: ResponseEntity<Grade>.
  • name: getGrade.
  • path variables: Long studentId, Long courseId.
  • returns a ResponseEntity with no data and a status of 200.

Postman

  • Create a request called Read Grade.
  • Make a GET request.

Response: 200 OK.

POST Request

  • method handles POST requests made on /grade/student/{studentId}/course/{courseId}.
  • return type: ResponseEntity<Grade>.
  • name: saveGrade.
  • deserializes incoming JSON properties into a Grade object.
  • path variables: Long studentId, Long courseId.
  • returns a ResponseEntity which re-serializes the object into a JSON with a status code of 201.

Postman

  • Create a request called Create Grade.
  • Make a POST request that sends the following JSON:
{ "score": "A+" }

Response: 201 Created

{ "id": null, "score": "A+" }

PUT Request

  • method handles PUT requests made on /grade/student/{studentId}/course/{courseId}.
  • return type: ResponseEntity<Grade>.
  • name: updateGrade.
  • deserializes incoming JSON properties into a Grade object.
  • path variables: Long studentId, Long courseId.
  • returns a ResponseEntity which re-serializes the object into a JSON with a status code of 200.

Postman

  • Create a request called Update Grade.
  • Make a PUT request that sends the following JSON:
{ "id": 1, "score": "A+" }

Response: 200 OK

{ "id": 1, "score": "A+" }

DELETE Request

  • method handles DELETE requests made on /grade/student/{studentId}/course/{courseId}.
  • return type: ResponseEntity<HttpStatus>.
  • name: deleteGrade.
  • path variables: Long studentId, Long courseId.
  • returns a ResponseEntity with a status code of 204.

Postman

  • Create a request called Delete Grade.
  • Make a DELETE request.

Response: 204 No Content.

GET Request

  • method handles GET requests made on /grade/student/{studentId}.
  • with return type: ResponseEntity<List<Grade>>.
  • name: getStudentGrades.
  • path variable: Long studentId.
  • returns a ResponseEntity with a status code of 200.

Postman

  • Create a request called Read Student Grades.

  • Make a GET request.

Response: 200 OK.

GET Request

  • method handles GET requests made on /grade/course/{courseId}.
  • with return type: ResponseEntity<List<Grade>>.
  • name: getCourseGrades.
  • path variable: Long courseId.
  • returns a ResponseEntity with a status code of 200.

Postman

  • Create a request called Read Course Grades.
  • Make a GET request.

Response: 200 OK.

GET Request

  • method handles GET requests made on /grade/all.
  • with return type: ResponseEntity<List<Grade>>.
  • name: getGrades.
  • returns a ResponseEntity with a status code of 200.

Postman

  • Create a request called Read Grades.
  • Make a GET request.

Response: 200 OK.

Final Touches

Save every request

Screen Shot 2022-07-22 at 1.28.29 AM.png

Create a new folder called Grade. Drag every Grade request there.

Screen Shot 2022-07-22 at 2.05.31 AM.png

Good Luck!

Feedback Summary
5.0
3 students
5

100%
4

0%
3

0%
2

0%
1

0%
Written Reviews
There are no written reviews yet.