Re: [api-craft] RESTful way to delete one Item in a collection behind a resource

126 views
Skip to first unread message
Message has been deleted

Ian Joyce

unread,
May 10, 2013, 10:28:19 AM5/10/13
to api-...@googlegroups.com
If I'm understanding you correctly I would try something like

    DELETE /users/123/followers/{followerId}

--Ian


On Fri, May 10, 2013 at 7:39 AM, maddin2code <martin....@gmail.com> wrote:
Hey Guys,

my RESTful API is working in progress, at the moment I'm thinking about the best RESTful way to delete one single item in a collection behind a resource.

The URL structure for each resource is

/resource/ -> collection of resource type
/resource/id/ -> single resource of type
/resource/id/collection -> a collection bounded to the single resource

An example, this:

GET /users/123/followers

represents the followers of user 123.

The followers are also resources of type users. Which HTTP Method should I use to delete one user as follower of user 123?

I think this is correct:

DELETE /users/123/followers 

I could work with query parameters to submit the id of the user who wants to unfollow user 123, or I use the current user indicated by session. Of course, in the application, to process this request, I delete the relation between the to users (type follow).

For my colleagues it looks like I delete the entire follower collection and some of them once to use PUT instead of DELETE because it is more an update and not a deletion. But I already use PUT to add a user as follower to the collection, if I would also use PUT to delete I need a query parameter to decide which action should be done.

What is the best in your RESTful eyes?

Greetings
Martin

--
You received this message because you are subscribed to the Google Groups "API Craft" group.
To unsubscribe from this group and stop receiving emails from it, send an email to api-craft+...@googlegroups.com.
Visit this group at http://groups.google.com/group/api-craft?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

sune jakobsson

unread,
May 11, 2013, 4:09:17 PM5/11/13
to api-...@googlegroups.com
+1

Youssef Boubdir

unread,
May 23, 2013, 9:22:05 AM5/23/13
to api-...@googlegroups.com
I think, the most appropriate RESTful url is :

DELETE /users/123/followers/:id
Reply all
Reply to author
Forward
0 new messages