Using an empty PUT in a REST service

I am wondering if it is correct to use a PUT request with an empty body.

The service just clones the existing object and saves it with a new id like

PUT / object / clone / {objectId}

Is it correct?

+3


source to share


3 answers


According to this (the part about REST methods):

https://docs.oracle.com/cd/E38689_01/pt853pbr0/eng/pt/tibr/concept_UnderstandingRESTServiceOperations.html



it's better to use a POST request for this while you are creating a new resource using an existing url.

+3


source


Since you are creating a new item that is a legal solution. Better yet would be to use POST.



+1


source


If you are doing a true RESTful approach using PUT / PATCH it has little effect, although PUT / PATCH is used in some schools of thought primarily to update / edit an existing resource rather than create it. If after this thinking the POST request makes more sense.

If I was posed with this dilemma, I would say that a POST request would be more viable to create (as it was created prior to implementation, not the language used to request its build).

+1


source







All Articles