Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using empty PUT on a REST service

Tags:

rest

http

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?

like image 721
Samuel García Avatar asked Dec 06 '25 09:12

Samuel García


2 Answers

According to this (part about REST-methods):

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

it is better to use the POST-request for this, as long as you are creating a new resource using the existing URL.

like image 77
Artem Moskalev Avatar answered Dec 09 '25 14:12

Artem Moskalev


Since you are creating new element that is legitimate solution. Even better would be to use POST.

like image 26
Marcin Szymczak Avatar answered Dec 09 '25 13:12

Marcin Szymczak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!