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

Updating blog post

  • Request: PATCH /posts/1?title=Modified%20Post HTTP/1.1
  • Response:
{id:1, title:"Modified Post", content:"This is an awesome post", link:"posts/1" }
  • Response code: 200 OK

Note, if a blog post with the ID provided (that is 1 in this case) does not exist, it should return the response code 404 that means resource not found.

Also, we have used PATCH instead of PUT for the update since PATCH is used to modify all or some attributes of a record while PUT is used for modifying a whole record just like replacing an old record with a new one. So, if we use PUT and pass only one attribute, the other attributes will become empty. In the case of PATCH, it will only update the attribute that is passed and other attributes remain untouched.

主站蜘蛛池模板: 临颍县| 浪卡子县| 贵南县| 九寨沟县| 凤庆县| 阿克| 湾仔区| 英吉沙县| 长顺县| 株洲县| 宁海县| 清河县| 莱阳市| 舒兰市| 鄂托克前旗| 广汉市| 团风县| 巍山| 灵川县| 泰来县| 沙坪坝区| 全椒县| 广河县| 泗洪县| 大邑县| 剑川县| 黄大仙区| 遵义市| 阜城县| 唐海县| 界首市| 郯城县| 巴塘县| 沧州市| 靖宇县| 北票市| 依兰县| 鸡东县| 南靖县| 浠水县| 广元市|