- 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.
- C語言程序設計實踐教程(第2版)
- jQuery Mobile Web Development Essentials(Third Edition)
- UML和模式應用(原書第3版)
- Objective-C Memory Management Essentials
- 教孩子學編程:C++入門圖解
- 重學Java設計模式
- 手把手教你學C語言
- Python編程:從入門到實踐
- Arduino家居安全系統(tǒng)構(gòu)建實戰(zhàn)
- Java Web開發(fā)詳解
- Python語言實用教程
- Vue.js 2 Web Development Projects
- 運維前線:一線運維專家的運維方法、技巧與實踐
- Android應用開發(fā)深入學習實錄
- Web Developer's Reference Guide