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

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.

主站蜘蛛池模板: 南涧| 上高县| 嘉义县| 乌鲁木齐县| 盐池县| 贵德县| 汉寿县| 鄂尔多斯市| 张家川| 博野县| 高安市| 成都市| 乌审旗| 钟祥市| 阿克苏市| 洞口县| 维西| 原平市| 恩施市| 中山市| 志丹县| 斗六市| 大荔县| 成安县| 潮安县| 周宁县| 龙胜| 吉木乃县| 新津县| 青田县| 绍兴市| 鄂尔多斯市| 峨边| 文昌市| 漳州市| 阳城县| 永年县| 赤峰市| 宁南县| 湟中县| 高邮市|