0% found this document useful (0 votes)
3 views

HTTP_Methods_CheatSheet

The document provides an overview of the four main HTTP methods: GET, POST, PUT, and DELETE, detailing their uses and properties. GET is for retrieving data, POST is for creating resources, PUT is for updating existing resources, and DELETE is for removing resources. Best practices are also outlined, emphasizing the importance of server-side validation and authorization for all requests.

Uploaded by

yanyan02089
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

HTTP_Methods_CheatSheet

The document provides an overview of the four main HTTP methods: GET, POST, PUT, and DELETE, detailing their uses and properties. GET is for retrieving data, POST is for creating resources, PUT is for updating existing resources, and DELETE is for removing resources. Best practices are also outlined, emphasizing the importance of server-side validation and authorization for all requests.

Uploaded by

yanyan02089
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

HTTP Methods Cheat Sheet (GET, POST, PUT, DELETE)

Overview

HTTP methods define the action to be performed on a resource. The four most common are GET,

POST, PUT, and DELETE.

Each one is used depending on what kind of interaction the client needs to make with the server.

GET

Use: Retrieve data (read-only)

Properties:

- Parameters appear in the URL (query string)

- Can be bookmarked or cached

- Should not modify server data

Example Scenarios:

- Viewing a product page: GET /product?id=25

- Searching inventory: GET /inventory?search=brake+fluid

POST

Use: Create a new resource or submit data

Properties:

- Parameters sent in the request body (hidden)

- Not cached or saved in browser history


- Can modify server state (e.g. database)

Example Scenarios:

- Logging in: POST /login

- Adding a new sale: POST /add_sale.php

- Uploading a file: POST /upload

PUT

Use: Update an existing resource completely

Properties:

- Similar to POST but used for full updates

- Usually sends all fields of the record

Example Scenarios:

- Updating user profile: PUT /users/7

- Replacing inventory info: PUT /inventory/123

DELETE

Use: Delete a resource

Properties:

- Often done through URL or AJAX

- Removes the target resource identified by the URL

Example Scenarios:
- Deleting a sale: DELETE /sales/45

- Removing a staff member: DELETE /staff/8

Best Practices

- Use GET for data retrieval only.

- Use POST when submitting forms or creating new data.

- Use PUT for updating full records.

- Use DELETE for removing data.

- Always validate and authorize requests on the server side.

You might also like