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

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.

主站蜘蛛池模板: 鲁山县| 肃南| 临高县| 如东县| 惠东县| 潼南县| 潼南县| 武胜县| 正安县| 甘谷县| 连江县| 铜梁县| 即墨市| 晋江市| 建湖县| 建湖县| 靖江市| 吉木萨尔县| 石家庄市| 长阳| 兴海县| 旌德县| 久治县| 柘荣县| 博野县| 新绛县| 潢川县| 曲阳县| 东至县| 布尔津县| 连平县| 竹北市| 湖口县| 万州区| 吴忠市| 呼玛县| 犍为县| 青神县| 噶尔县| 泾阳县| 孝感市|