Understanding HTTP
- REST APIs embraces all aspects of HTTP (Hyper Text Transfer Protocol)
- The Request sent by the client can be summarized as
Request = <Method> <Request-URI> <HTTP-Version>
- Example:
GET /todos/1 HTTP/2
- The Response from the Server can be summarized as
Response = <HTTP-Version> <Status Code> <Reason-Phrase>
- Example:
HTTP/2 200
HTTP Methods
- We will be using four most common HTTP Methods
- GET: This method requests a representation of specified Resource. Requests using GET should only retrieve data. (Retrieve)
- PUT: This method replaces the current representation of the target resource (Update)
- POST: This method submits an entity to the specified resource for creation. (Create)
- DELETE: This method creates a request to DELETE some resource (Delete)
- There are other HTTP Methods
- HEAD
- OPTIONS
- PATCH
- CONNECT
- TRACE
HTTP Response Status Codes
- Status Code By Category
| Category | Description |
| ——- | ———– |
| 1xx | Information |
| 2xx | Success: Indicates, the client request was accepted succesfully |
| 3xx | Redirection: Indicates that the client must take some additional actions to complete their request|
| 4xx | Client Error: This category of error status codes points the finger at clients |
| 5xx | Server Error: The server takes responsibility for these error status |
Activity 1: Lets create a HTTP GET Request from PostMan
- Creating a HTTP Request to fake rest api
- Selecting other HTTP Methods