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

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.

主站蜘蛛池模板: 阜宁县| 公安县| 景谷| 大洼县| 桃园市| 黔江区| 杭锦旗| 桂平市| 苗栗市| 额敏县| 墨玉县| 辽宁省| 泰和县| 天祝| 娱乐| 姜堰市| 娄底市| 宁蒗| 丹阳市| 杭锦后旗| 岑溪市| 岫岩| 河津市| 扬州市| 金平| 海丰县| 福泉市| 长阳| 马山县| 郑州市| 恩施市| 钟祥市| 淳安县| 虹口区| 高雄市| 廉江市| 北川| 澄江县| 无为县| 西盟| 通河县|