Web Development Questions Flashcards

1
Q

What is REST API

A

REST (Representational State Transfer) is an architectural style for designing networked applications. RESTful APIs (Application Programming Interfaces) are a type of web service that adhere to the principles and constraints of the REST architectural style.

In a REST API, resources (such as data objects or services) are identified by unique URIs (Uniform Resource Identifiers). Clients can interact with these resources using standard HTTP methods, including GET, POST, PUT, PATCH, and DELETE, to perform operations on the resources.

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

What is the difference between PUT and PATCH?

A

The PUT method is used to update a resource by replacing the entire representation of the resource with the new representation provided in the request. In other words, it performs a complete replacement of the resource at the specified URI.

PUT /api/users/1
{
“name”: “John Doe”,
“email”: “john.doe@example.com”
}

The PATCH method is used to update a resource with partial changes. Unlike PUT, PATCH doesn’t require sending the entire representation of the resource. Instead, it only includes the specific changes that need to be applied to the resource.

PATCH /api/users/1
{
“name”: “John Doe”
}

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

What is a 500, 401 status code?

A

500 Internal Server Error:
The 500 status code is a generic server error response. It indicates that the server encountered an unexpected condition that prevented it from fulfilling the request. This could be due to various reasons such as a bug in the server-side code, a database error, or a misconfiguration. The 500 status code is typically used to indicate that the server is aware of the error, but the exact cause is unknown or cannot be disclosed to the client.

401 Unauthorized:
The 401 status code indicates that the client’s request requires authentication, but the client has not provided valid credentials or has not authenticated itself. In other words, the client is not authorized to access the requested resource. The server sends a 401 status code to prompt the client to provide valid credentials (such as a username and password) or to authenticate using another method (such as token-based authentication). Upon receiving a 401 response, the client typically prompts the user to provide the necessary credentials for authentication.

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

What are some common HTTP codes?

A

Informational (1xx):

100 Continue
101 Switching Protocols
102 Processing
Success (2xx):

200 OK
201 Created
202 Accepted
204 No Content
Redirection (3xx):

300 Multiple Choices
301 Moved Permanently
302 Found
304 Not Modified
307 Temporary Redirect
Client Error (4xx):

400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
409 Conflict
418 I’m a teapot (a humorous code)
Server Error (5xx):

500 Internal Server Error
501 Not Implemented
503 Service Unavailable
504 Gateway Timeout
511 Network Authentication Required

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