REST updating multiple resources

前端 未结 1 1466
野趣味
野趣味 2020-12-18 05:46

I\'ve tried searching this, but I haven\'t managed to find an answer which would fit my needs.

Considering I currently have the following route:

[GET         


        
相关标签:
1条回答
  • 2020-12-18 06:01

    In a RESTful API the URL should define the object of the transaction, and the verb the action.

    So GET /items should return all items.

    GET /items/1 should return the item with id 1.

    It follows that the multiple ids should be part of the resource definition (url). So GET /items/1,2,3 should return the 3 appropriate items.

    Therefore, to apply a partial update to many ids:

    [PATCH] /items/1,2,3
    

    Then within the body of the PATCH or PUT, you can provide the information to be updated (assuming you are sending a JSON body).

    {"updateField": "newValue"}
    
    0 讨论(0)
提交回复
热议问题