- Building RESTful Web Services with PHP 7
- Haafiz Waheed ud din Ahmad
- 130字
- 2021-07-03 00:02:19
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.
推薦閱讀
- PWA入門與實踐
- C語言程序設計基礎與實驗指導
- INSTANT Mercurial SCM Essentials How-to
- R大數據分析實用指南
- Building Wireless Sensor Networks Using Arduino
- Learning Modular Java Programming
- Odoo 10 Implementation Cookbook
- BeagleBone Robotic Projects(Second Edition)
- 零基礎看圖學ScratchJr:少兒趣味編程(全彩大字版)
- Java EE 7 Development with WildFly
- 網絡綜合布線與組網實戰指南
- Building Microservices with Go
- 虛擬現實:引領未來的人機交互革命
- OpenCV:Computer Vision Projects with Python
- Scratch 3少兒交互式游戲編程一本通