Wednesday, 11 September 2013

What is the restful way to represent a resource clone operation in the URL?

What is the restful way to represent a resource clone operation in the URL?

I have REST API that exposes a complex large resource and I want to be
able to clone this resource. Assume that the resource is exposed at
/resources/{resoureId}
To clone resource 10 I could do something like.
GET /resources/10
POST /resources/ body of put containing a duplicate of the representation
by GET /resources/10 without the id so that the POST creates a new
resource.
The problem with this approach is that the resource is very large and
complex it really makes no sense to return a full representation to the
client and then have the client send it back as that would be just a total
waste of bandwidth, and cpu on the server. Cloning the resource on the
server is so much easier so I want to do that.
I could do something like POST /resources/10/clone or POST
resources/clone/10 but both of these approaches feel wrong because the
verb in the URL.
What is the most "restful/nouny" way to build url that can be used in this
type of situation?

No comments:

Post a Comment