Reputation: 2225
I'm wondering if it is correct to use a PUT request with an empty body.
The service just clones an existing object and persists it with a new identifier, like
PUT /object/clone/{objectId}
Is this correct?
Upvotes: 3
Views: 916
Reputation: 14620
If you are following a true RESTful approach using PUT/PATCH makes a little sense though PUT/PATCH in some schools of thought is used predominantly to update/edit an existing resource rather than create. If following this thinking a POST request would make more sense.
If I was posed with this dilemma I'd say a POST request would be more viable for creation (how it is created is down to implementation not the language used to request it's construction).
Upvotes: 1
Reputation: 11453
Since you are creating new element that is legitimate solution. Even better would be to use POST.
Upvotes: 1
Reputation: 5828
According to this (part about REST-methods):
it is better to use the POST-request for this, as long as you are creating a new resource using the existing URL.
Upvotes: 3