1
votes

I have a RESTful API with Spring HATEOAS. I try to stick to Level 3. And now I have a resource and operations that can be performed on it. One of them is related to Profile resource. Profiles can be cloned. And now I wonder how to do it properly. Clone operation already creates new profile. I was thinking about:

  • api/profile/{id}/clone - POST. url contains id of the profile that should be cloned. Other required parameters are in request body
  • api/profile/clone - POST. all information is in request body.

Which is better? Or maybe both are not proper ways of implementing this actions and other approach should be used?

1
If the URL contains a verb it's definitely not REST. Strip /clone from the second alternative, then you have it. - a better oliver
if I strip clone, how do I know that operation is cloning? - dragonfly
Because it has the appropriate media type. - a better oliver

1 Answers

0
votes

You can do POST request to api/profile/{id}/clone resource, is it absolutely right!

Just remember that POST operatios tend to be unsafed, and not imdepotent, what means that each new incoming request to your resource will create a new one...

http://www.restapitutorial.com/lessons/idempotency.html