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

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.

主站蜘蛛池模板: 古浪县| 安塞县| 徐州市| 扎囊县| 平远县| 白山市| 合水县| 平顶山市| 社旗县| 久治县| 济源市| 岫岩| 封开县| 天祝| 福州市| 衡水市| 长兴县| 昌平区| 永春县| 郓城县| 渝中区| 元氏县| 林西县| 东丰县| 弋阳县| 诸城市| 淳安县| 临湘市| 长沙市| 杂多县| 黄梅县| 赤壁市| 西畴县| 芦山县| 吴江市| 察雅县| 淮阳县| 乌兰县| 庆云县| 宁武县| 巴青县|