Web API

Due: 11:00pm, Friday April 16, 2021

Max grace days: 2

Description

The goal for this assignment is to make a web API using Sqlite and PHP. This assignment contains the following files: students.db and students.php. You need to edit the students.php file.

We would like to make an API with “pretty URLs” like this:

However, due to limitations with the current server setup we cannot. We will “fake it” with the following URLs instead where {} indicates a placeholder value:

If the id value is not valid for certain operations (GET, PUT, DELETE), then the response should be:

HTTP/1.1 404 Not Found

For this assignment, we will not worry about validating the input. However if data is missing for the for the create (POST) or update (PUT) operations, then the response should be something like:

HTTP/1.1 422 Unprocessable Entity
Content-Type: application/json

{"error": "Invalid input"}

The HTTP headers can be set in PHP with the header function.

Note: The students.db file and the directory it is in must have write permissions in order for the Apache server to write to the file. To enable write permissions, execute the following two commands from within the assignment directory:

    chmod go+w students.db
    chmod go+w .

Turning in the Assignment

For this assignment, you must turn in a zip file containing the following files:

  1. students.php

Submit the zip file to the appropriate folder on D2L.

Grading Criteria

Grading (out of 100 points):