Difference between PUT и POST

🏠 | 💻 PC | Web |

This question can pop up during interview or when you create your own API.

In this article you can find four answers.

1. Novelty

POST sends new data to server.

PUT apllies some changes to already existing data.

2. Idempotency

PUT should be idempotent. It means that multiple identical PUT requests to same endpoint does not change API condition.

POST does not have to be idempotent.

3. Body

POST suggests, that data is sent in the request's body.

POST http://eth1.ru:8080/resource1/eventslist

Body:

{
  "itemID":"AB45636",
  "groupNo":"XZ100329",
  "weight":1395.00,
  "Distance":385.40,
  "Time":"2017-01-01T11:20:36.000+0000",
  "delayed":true
}

PUT suggests, everything is sent inside URL. No body.

PUT http://www.answerit.ru:8080/api/order/<int:put_id>

Argument against this version:

HTTP 1.1 allows body for all methods.

GET, HEAD and DELETE does not have body semantics defined, so body is ignored. PUT does not have this feature.

4. CRUD

PUT can be considered as a part of CRUD - it covers Create and Update. POST is more problematic if you need to put it to CRUD.

This version is contraversal to 1 where new data creation is associated with POST.

You can practice creating PUT and POST requests here

Internal

If you whant to check how HTTP methods work from the iside configure telnet or telnet in Windows and send requests.

Configuration of telnet in Windows is described here .

As an alternative to telnet sockets can be used.

Resume

According to some real life experience difference between POST and PUT can change on different servers.

Logical difference between POST and PUT from GET is obvious - they are addind data and GET fetches data.

PUT and POST can be processed in a manner that is more common for certain developer.

It can be helpful to ask direct questions from software developer.

🛠 Useful tips
🖽 Html
🖌 CSS
Joomla
UTM tags
URLencode
↬ Site page redirects
↔ Responsive website design
Setting up a Yandex mailbox
Which hosting to choose
How to migrate a site
Yandex Metrica
Difference between POST and PUT
Word Press
SEO
Website testing
A numeric character reference expanded to the C1 controls range.
JavaScript
.webp
Flask
Django
How to specify a canonical page

Article author: Andrei Olegovich

Related articles
Web
IP
HTML
CSS
Network mask
JavaScript
PHP
NodeJS
NPM
Gulp
URLencode
Which hosting to choose
PUT vs POST
Flask
Django

Search this site

Channel @aofeed Chat @aofeedchat

Contacts and cooperation:
I recommend our hosting beget.com
Write to info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: