How to support Partial Updates (PATCH) in REST

前端 未结 3 1592
囚心锁ツ
囚心锁ツ 2021-01-30 17:54

I want to implement the partial updates for my resource as i have large resource and want to update the partial information from it.I have gone through the following links but n

3条回答
  •  别那么骄傲
    2021-01-30 18:15

    You should use method PATCH like described in RFC-7386 "json merge PATCH".

    E.g. if you want to change value of "a" and removing "f" in resource like:

       {
         "a": "b",
         "c": {
           "d": "e",
           "f": "g"
         }
       }
    

    You can achive this by sending:

           PATCH /target HTTP/1.1
           Host: example.org
           Content-Type: application/merge-patch+json
    
           {
             "a":"z",
             "c": {
               "f": null
             }
           }
    

提交回复
热议问题