- 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.
推薦閱讀
- iOS Game Programming Cookbook
- AngularJS入門與進階
- Java程序設(shè)計與開發(fā)
- Intel Galileo Essentials
- Getting Started with ResearchKit
- 樂學Web編程:網(wǎng)站制作不神秘
- PyTorch自然語言處理入門與實戰(zhàn)
- Scratch 3.0少兒編程與邏輯思維訓練
- Learning Data Mining with R
- 機器學習與R語言實戰(zhàn)
- 一本書講透Java線程:原理與實踐
- UI設(shè)計全書(全彩)
- Azure Serverless Computing Cookbook
- 實戰(zhàn)Java高并發(fā)程序設(shè)計(第2版)
- App Inventor少兒趣味編程動手做