KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to finalise on a restful url structure for the wishlist section of a site I'm working on. It's a pretty simple model, a user can have many wishlists and each wishlist can contain many products. Currently I have the obvious CRUD URLs to manipulate the wishlist itself : GET account/wishlists.json GET account/wishlists/{id}.json POST account/wishlists.json?name=My%20Wishlist POST account/wishlists/{id}.json?name=My%20New%20Name DELETE account/wishlists/{id}.json However, I don't think I know how to structure the URLs that would add/remove a product to a wishlist :( Here are my current choices : 1) Have the product to add as part of the URL and use the HTTP verb to define my action POST account/wishlist/{id}/product/{product_id}.json DELETE account/wishlist/{id}/product/{product_id}.json or 2 ) Have the action as part of the URL and the product id as part of the payload POST account/wishlist/{id}/add.json?product_id={product_id} POST account/wishlist/{id}/remove.json?product_id={product_id} (1) is clean and, as far as I can tell it's pretty RESTful but doesn't allow things like adding multiple products easily etc. I'm also a bit concerned about using the DELETE verb - I'm not deleting the product or the wishlist, I'm just removing one from the other. (2) is more explicit but veers away from REST - I wouldn't be just referring to the resource in the url, I would be referring to an operation on that resource :( Any advice on which of the above would be more correct would be very helpful! (If there's a third option that's better than mine, feel free to correct me!)
Tags (comma-separated)
Save Edits
Cancel