Skip to content
BENIBIX Learn

HTTP Methods: GET vs POST

Level 4 · HTTP, the language of the web

What GET, POST, PUT, PATCH and DELETE each ask a server to do. Where the data goes, in a query parameter or in the request body.

Course contentsLesson 10 of 13

After this lesson you can

  • Pick the right method for a job
  • Tell PUT from PATCH
  • Say when data goes in the query or the body

12 mincovers 8 glossary entries

Worth reading first: HTTP Requests and Responses

What each HTTP method asks for

The method is the first word of an HTTP request, and it says what to do. There are five common ones. GET reads. POST adds something new. PUT replaces a thing whole. PATCH changes part of it. DELETE removes it. The same address can take all five and do something different each time.

GET only reads and changes nothing. That makes it safe to repeat, to save as a bookmark and to keep a copy of. Opening a page, loading an image and searching a shop are all GET requests.

POST sends new data to be added. Placing an order, posting a comment and signing up are POST requests. Sending the same POST twice can make two orders. That is why a browser warns you before it sends a form again.

PUT and PATCH both change a thing that exists. PUT sends the whole new version and replaces the old one. PATCH sends only the fields that change. Sending a PUT with one field missing can wipe that field out.

Data rides in one of two places. A query parameter sits in the address after a question mark, such as ?page=2. It suits short facts for reading, such as a search word or a page number. The request body sits after the headers and suits larger data or anything private, such as a form.

Addresses get saved in browser history, in server logs and in links people share. So anything after the question mark should be safe for others to see. A password or a card number always goes in the body of a POST. It never goes in the address.

A common mistake is to use GET for something that changes data, such as a link that deletes an item. Browsers and tools fetch GET links ahead of time to make pages faster. One of them can follow that link. The item is gone with no one clicking anything.

The five common methods

MethodWhat it doesHas a bodySafe to repeat
GETReads a thingNoYes
POSTAdds a new thingYesNo, it may add two
PUTReplaces a thing wholeYesYes
PATCHChanges part of a thingYesNot always
DELETERemoves a thingUsually notYes

Which one to use

  1. 1

    Use GET

    When you only read, such as opening a page or running a search.

  2. 2

    Use POST

    When you make something new, such as an order, a comment or an account.

  3. 3

    Use PUT

    When you send the whole new version of a thing to replace the old one.

  4. 4

    Use PATCH

    When you change one or two fields and leave the rest alone.

  5. 5

    Use DELETE

    When you remove a thing, such as a saved address or an old post.

The address names the thing. The method says what to do to it.

Worked example

A shop's search and checkout

A customer searches the shop for blue mugs. The browser sends GET /search?q=blue+mugs. The search word rides in the address, so the result page can be bookmarked.

At checkout, the browser sends POST /orders. The address, card details and two mugs go in the request body, where they never show up in history.

The words for this lesson8

Check yourself

Where should a password go in an HTTP request?

Finished this lesson?

Marking it complete also marks its 8 glossary entries learned, which updates your roadmap and your saved page. 0 are already marked.