Web Requests - CRUD API Flashcards
What does CRUD stand for in the context of APIs?
Create, Read, Update, Delete
Which HTTP method is used to create a new entry in a database via an API?
POST
Which HTTP method is used to read data from a database via an API?
GET
Which HTTP method is used to update an existing entry in a database via an API?
PUT
Which HTTP method is used to delete an entry from a database via an API?
DELETE
Fill in the blank: The HTTP method _______ is used to partially update an entry in an API.
PATCH
What format is the response from the API typically sent in?
JSON
What command is used to format JSON output from cURL in the examples?
jq
True or False: The DELETE method requires the name of the entity to be deleted in the URL.
True
What header must be set when sending JSON data in a POST request?
Content-Type: application/json
What would the URL look like to update the city ‘london’ in the database?
http://<SERVER_IP>:<PORT>/api.php/city/london</PORT></SERVER_IP>
What happens if a PUT request is made for a non-existing entry in some APIs?
It may create a new entry.
What is required for user authentication when using an API?
A cookie or an authorization header (e.g. JWT)
List the four main operations that APIs perform on a database.
- Create
- Read
- Update
- Delete
Describe the role of user access control in API operations.
It limits what actions can be performed and what results can be seen.
What is the purpose of the HTTP OPTIONS method in relation to PUT and PATCH?
To see which of the two methods is accepted by the server.
Fill in the blank: To retrieve all entries in a table, an empty string is passed to the API like this: /city/_______.
What command would you use to delete a city named ‘New_HTB_City’?
curl -X DELETE http://<SERVER_IP>:<PORT>/api.php/city/New_HTB_City</PORT></SERVER_IP>
What indicates that an entry no longer exists after a DELETE request?
An empty array is returned.