For the next two assignments we will be implementing and extending the Course Organizer application that we started in Unit 8. Your first step should be to review the application screenshots which illustrate how the application works.
Based on the application requirements, in this unit you will code the API. For your final project, you and your teammates will need to define an API. For practice, I therefore suggest that you first come up with your own list of functions, based on the screenshots. Then compare your list to the table below.
NOTES:
Action | Method | URL path | Parameters | Example |
---|---|---|---|---|
Read list of courses | GET | /courses | http://localhost:3000/api/courses | |
Read specific course | GET | /course | courseid | http://localhost:3000/course/5a2c3329646521cb863c546b/ |
Create new assignment | POST | /courses/courseid/assignments | courseid | http://localhost:3000/courses/5a2c3329646521cb863c546b/assignments |
Get all assignments | GET | /courses/courseid/assignments | courseid | http://localhost:3000/courses/5a2c3329646521cb863c546b/assignments |
Update an assignment | PUT | /courses/courseid/assignments/assignmentid | courseid, assignmentid | PUT /api/courses/5a2c3329646521cb863c546b/assignments/5a2c3329646521cb863c546a |
Delete an assignment | DELETE | /courses/courseid/assignments/assignmentid | courseid, assignmentid | DELETE /api/courses/5a2c3329646521cb863c546b/assignments/5a2c3329646521cb863c5469 |
We will use Postman to test the API. Your submission will be a "script" that shows the Postman queries and results. In unit 9 you created a json file to load your courses collection. I suggest that you use that file to begin the testing process (edit as needed to simplify queries). You MUST use realistic data - no lorem ipsum or gibberish. If you want to "reset" your database, an easy way is to:
use [your_database_name]
db.courses.drop()
to remove all documents.
To create your "script" you will capture screenshots of Postman showing each of the required API calls. Include these in a pdf or html file. Annotate each screen shot so the grader can easily identify each requirement. For some APIs it's good to include more than one screenshot (e.g., the POST to add an assignment, I show both the returned status of 201 AND the course with the assignment added).
You may want to use the following html code to annotate your figures:
<figure>
<img src="images/Postman/GET_listOfCourses.jpg" width="600px" alt="List of courses">
<figcaption>GET list of courses</figcaption>
</figure>
Take a look at this Script of API calls. Your submission should be similar.
Postman is fairly intuitive, but a few things that I had to figure out:
x-www-form-urlencoded
to enter your data (figure 6.6
is similar).