- Building RESTful Web Services with PHP 7
- Haafiz Waheed ud din Ahmad
- 176字
- 2021-07-03 00:02:17
Update operation
There can be two types of update operations:
- Update some attributes of a particular record
- Replace that particular record completely with a new one
Only thing that change to perform these two operations: HTTP method.
With the Update operation, to update some of attributes of the resource use:
HTTP method: PATCH
While to replace the whole resource use:
HTTP method: PUT
The URI and the parameters will remain the same:
URI: /{resource}/{resource_id}
Parameters: There can be multiple parameters in a query string. Initially, people try to pass these parameters in the body but actually, the PATCH and PUT parameters are passed using a query string.
Result: This should update or replace the resource based on the HTTP method.
Here, resource_id will be the ID of the resource which can be found from the List operation's result. Again, practically using PATCH or PUT will not make any difference but based on REST standards PATCH should be used for updating the different attributes of a record while PUT should be used for replacing the whole resource.
- 技術(shù)領(lǐng)導(dǎo)力:程序員如何才能帶團(tuán)隊(duì)
- Java:Data Science Made Easy
- Java Web程序設(shè)計(jì)
- C語言程序設(shè)計(jì)
- Scala編程(第5版)
- FFmpeg開發(fā)實(shí)戰(zhàn):從零基礎(chǔ)到短視頻上線
- Python期貨量化交易實(shí)戰(zhàn)
- Practical GIS
- Learning Android Application Testing
- 現(xiàn)代C:概念剖析和編程實(shí)踐
- 微前端設(shè)計(jì)與實(shí)現(xiàn)
- Java Web動(dòng)態(tài)網(wǎng)站開發(fā)(第2版·微課版)
- ASP.NET jQuery Cookbook(Second Edition)
- 熱處理常見缺陷分析與解決方案
- PHP編程(第4版)