Question: 4 . 1 Accessing JSON APIs Create a program that displays the following menu to the user: Read all students Get student by id Add
Accessing JSON APIs
Create a program that displays the following menu to the user:
Read all students
Get student by id
Add student
Edit student
Remove student
Exit
then performs the choice entered by the user.
Note: The address of the server is localhost and the port is This must be used as the base URL for all requests.
Note : If something is wrong with a request you send, the server will answer with Bad Request.
Read all students
Connects to the server and send a get request to the students resource.
Print information about every student returned by the server.
Expected output: id: name: Kathryn Boyd, email: kathrynb@uia.no year:
Get student by id
Asks the user for a student id then connects to the server and send a get request to the students resource.
Print information about the result returned by the server.
Expected output per status code:
OK
id: name: Kathryn Boyd, email: kathrynb@uia.no year:
Not Found
Student not found
Add student
Asks the user for the following in order:
Name
Email
Year
Then sends a POST request to students to add the new student. The format of the data must be:
"name": "William Canez",
"email": "williamc@uia.no
"year":
And prints out the response. The server will respond with Created if everything went OK
Expected output: Added student: id: name: Kathryn Boyd, email: kathrynb@uia.no year:
Edit student
This is very similar to add student, so I recommend solving that one first then reusing code.
Asks the user for the following in order:
Student id
Name
Email
Year
Then sends a PUT request to students to modify the existing student. The format of the data must be:
id:
"name": "William Canez",
"email": "williamc@uia.no
"year":
Expected output per status code:
OK if everything went OK
Student was edited successfully
Not Found if the student doesn't exist
Student not found
Remove student
Asks the user for a student id then sends a DELETE request to students to remove the existing student. No data is sent.
Expected output per status code:
No Content if everything went OK
Student was removed successfully
Not Found if the student doesn't exist
Student not found
Exit
Exits the program.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
