Web Requests - CRUD API Flashcards

1
Q

What does CRUD stand for in the context of APIs?

A

Create, Read, Update, Delete

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which HTTP method is used to create a new entry in a database via an API?

A

POST

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which HTTP method is used to read data from a database via an API?

A

GET

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which HTTP method is used to update an existing entry in a database via an API?

A

PUT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which HTTP method is used to delete an entry from a database via an API?

A

DELETE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Fill in the blank: The HTTP method _______ is used to partially update an entry in an API.

A

PATCH

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What format is the response from the API typically sent in?

A

JSON

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What command is used to format JSON output from cURL in the examples?

A

jq

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

True or False: The DELETE method requires the name of the entity to be deleted in the URL.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What header must be set when sending JSON data in a POST request?

A

Content-Type: application/json

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What would the URL look like to update the city ‘london’ in the database?

A

http://<SERVER_IP>:<PORT>/api.php/city/london</PORT></SERVER_IP>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What happens if a PUT request is made for a non-existing entry in some APIs?

A

It may create a new entry.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is required for user authentication when using an API?

A

A cookie or an authorization header (e.g. JWT)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

List the four main operations that APIs perform on a database.

A
  • Create
  • Read
  • Update
  • Delete
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Describe the role of user access control in API operations.

A

It limits what actions can be performed and what results can be seen.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the purpose of the HTTP OPTIONS method in relation to PUT and PATCH?

A

To see which of the two methods is accepted by the server.

17
Q

Fill in the blank: To retrieve all entries in a table, an empty string is passed to the API like this: /city/_______.

18
Q

What command would you use to delete a city named ‘New_HTB_City’?

A

curl -X DELETE http://<SERVER_IP>:<PORT>/api.php/city/New_HTB_City</PORT></SERVER_IP>

19
Q

What indicates that an entry no longer exists after a DELETE request?

A

An empty array is returned.