Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 4123

RESTful patch and delete sub resources best practice [closed]

$
0
0

I have following object structure in my backend:

Offer with some fields and list of ProductOffers.

In reality in the UI, user can open his Offer, click EDIT button and modify, add new, delete existing productOffers, modify Offer fields. The he clicks OK (apply changes)

How to design a RESTful API for that?

Options I consider:

  1. Add a PATCH (or alternatively PUT) endpoint which will take a request with list of ProductOffers. That list will update existing productOffers, create new productOffers and if some productOffer is missing it's gonna be removed.
  2. Similar approach but adding a delete: true flag to the productOffer I want to remove
  3. PATCH will only add new productOffers if they come without id, or modify existing if they cam with id. Missing productOffer means nothing. Another request will come which will be a bulk DELETE.

Personally I think that option 2. is going to be the most handy for my needs, but I don't want to create a monster.

What u guys think?


Viewing all articles
Browse latest Browse all 4123

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>