🏠 | 💻 PC | Web |

Difference between PUT and POST methods

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.

🛠 Полезные советы
🖽 Html
🖌 CSS
Joomla
UTM-метки
URLencode
Переадресация страниц сайта
Адаптивный дизайн сайтов
Настройка почтового ящика на Яндекс
Какой хостинг выбрать
Как перенести сайт
Яндекс Метрика
Разница между POST и PUT
Word Press
SEO
Тестирование сайта
A numeric character reference expanded to the C1 controls range.
JavaScript
.webp
Flask
Django
Как указать каноническую страницу сайта
Share in social media: