Module 11: REST API
- First read this page then start the module with the GitHub classroom link below.
- Github Classroom Link: https://classroom.github.com/a/QI8tHHwn
Resources
Setup
Install the Thunder Client Lightweight Rest API Client for VS Code extension.
Exercise 1:
- Review the code in the Module 10 repository.
- Edit line 38 of
pizzaAPI.cpp
. Change the port number18080
to a unique port number between15000
and20000
.app.port(/* YOUR PORT NUMBER HERE */).run();
- Run the
make
command to build thepizzaAPI
.$ make
- Start the
pizzaAPI
by running$ ./pizzaAPI
- Using your web browser go to the following URL. Except change
cs01
to the machine that you are logged into. (no change if you are usingcs01
). Change the port number18080
to the port number you selected above in step 2.http://cs01:18080/api/toppings
- What was returned? Enter that into the
README.md
file in your module 10 GitHub repository. - Using your web browser go to the following URL. Except change
cs01
to the machine that you are logged into. (no change if you are usingcs01
). Change the port number18080
to the port number you selected above in step 2.http://cs01:18080/api/toppings/1
- What was returned? Enter that into the
README.md
file in your module 10 GitHub repository.
Exercise 2:
- Using the Thunder Client Lightweight Rest API Client for VS Code extension. Create a new request by clicking the “New Request” button.
- Create a new
GET
request like this one. Except changecs01
to the machine that you are logged into. (no change if you are usingcs01
). Change the port number18080
to the port number you selected above.
- Click the “Send” button. Then in the
README.md
file explain the status and the body of theResponse
. - In the
README.md
file explain the code in thepizzaAPI.cpp
that made this happen.
Exercise 3:
- Using the Thunder Client Lightweight Rest API Client for VS Code extension. Create a new request by clicking the “New Request” button.
- Create a new
GET
request like this one. Except changecs01
to the machine that you are logged into. (no change if you are usingcs01
). Change the port number18080
to the port number you selected above.
- Click the “Send” button. Then in the
README.md
file explain the status and the body of theResponse
. - In the
README.md
file explain the code in thepizzaAPI.cpp
that made this happen.
Exercise 4:
- Using the Thunder Client Lightweight Rest API Client for VS Code extension. Create a new request by clicking the “New Request” button.
- Create a new
PUT
request like this one. Except changecs01
to the machine that you are logged into. (no change if you are usingcs01
). Change the port number18080
to the port number you selected above. Note: you must also click theBody
tab and enter the JSON string shown to modify the topping.
- Click the “Send” button. Then in the
README.md
file explain the status and the body of theResponse
. - In the
README.md
file explain the code in thepizzaAPI.cpp
that made this happen.
Exercise 5:
- Using the Thunder Client Lightweight Rest API Client for VS Code extension. Create a new request by clicking the “New Request” button.
- Create a new
POST
request like this one. Except changecs01
to the machine that you are logged into. (no change if you are usingcs01
). Change the port number18080
to the port number you selected above. Note: you must also click theBody
tab and enter the JSON string shown to create the new topping.
- Click the “Send” button. Then in the
README.md
file explain the status and the body of theResponse
. - In the
README.md
file explain the code in thepizzaAPI.cpp
that made this happen.
Exercise 6:
- Using the Thunder Client Lightweight Rest API Client for VS Code extension. Create a new request by clicking the “New Request” button.
- Create a new
DELETE
request like this one. Except changecs01
to the machine that you are logged into. (no change if you are usingcs01
). Change the port number18080
to the port number you selected above.
- Click the “Send” button. Then in the
README.md
file explain the status and the body of theResponse
. - In the
README.md
file explain the code in thepizzaAPI.cpp
that made this happen.