🏠 | 💻 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
Как указать каноническую страницу сайта
Контакты и сотрудничество:
Рекомендую наш хостинг beget.ru
Пишите на info@urn.su если Вы:
1. Хотите написать статью для нашего сайта или перевести статью на свой родной язык.
2. Хотите разместить на сайте рекламу, подходящуюю по тематике.
3. Реклама на моём сайте имеет максимальный уровень цензуры. Если Вы увидели рекламный блок недопустимый для просмотра детьми школьного возраста, вызывающий шок или вводящий в заблуждение - пожалуйста свяжитесь с нами по электронной почте
4. Нашли на сайте ошибку, неточности, баг и т.д. ... .......
5. Статьи можно расшарить в соцсетях, нажав на иконку сети: