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

Since there is no copy or clone method in HTTP, it’s really up to you what you want to do. In this case a POST seems perfectly reasonable, but other standards have taken different approaches:

  • WebDAV added a COPY method.
  • Amazon S3 uses PUT with no body and a special x-amz-copy-source header. They call this a PUT Object - Copy.

Both of these approaches assume that you know the destination URI. Your example seems to lack a known destination uri, so you pretty much must use POST. You can’t use PUT or COPY because your creation operation is not idempotent.

If your service defines POST /resources as “create a new resource”, then why not simply define another way to specify the resource other than as the body of the POST? E.g. POST /resources?source=/resources/10 with an empty body.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)