官术网_书友最值得收藏!

PATCH

The PATCH verb is used to perform a partial update, for example, if we only wanted to update the name of our cat we could make a PATCH request only containing the details that we would like to change.

Request:

PATCH /v1/cats/12343 HTTP/1.1 
Content-Type: application/json
Content-Length: xxxx

{"weight": 9}

Response:

HTTP/1.1 204 No Body 
Content-Type: application/json
Content-Length: 0

In my experience PATCH updates are rarely used, the general convention is to use a PUT and to update the whole object, this not only makes the code easier to write but also makes an API which is simpler to understand.

主站蜘蛛池模板: 孟州市| 长兴县| 达孜县| 遵义县| 色达县| 滁州市| 精河县| 衡东县| 化德县| 潼南县| 曲阜市| 沙河市| 莱阳市| 大理市| 诸城市| 贵州省| 呼玛县| 洱源县| 依安县| 江永县| 五峰| 象山县| 大新县| 宁南县| 丽江市| 精河县| 湟源县| 宁蒗| 五河县| 崇义县| 崇阳县| 方正县| 湖南省| 梓潼县| 隆昌县| 南丹县| 安义县| 将乐县| 高碑店市| 平山县| 阜新|