You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
I don't know any specific HTTP rules about PUT and DELETE response bodies. I think that you can return what you want. But, PUT and DELETE generally don't need to return anything. Indeed, an appropriate HTTP status code (200, 201...) is sufficient.
So, the question is : What do you want to return ?
Anyway, we initially implement the RestTemplate like the official Spring RestTemplate way. Let's see the 2.5.6 section of the documentation about PUT method. That explains what PUT and DELETE methods only return void.
As @a-thomas said, PUT and DELETE don't normally require a response body, which is why we don't return anything in the put() and delete() convenience methods within RestTemplate. If a response body is desired, then using the exchange() method as @pyricau suggested, should give you what you need.
@a-thomas I have a common use case (the 9-months late use case, ah ah)
It's common to identify all business objects with a unique ID.
When you create a new object, you call POST with all the required attributes except this ID, because it's filled by the server.
How do you get this ID if you don't return anything ? You'd have to GET the whole list to retrieve the newly created one. Almost all POST methods in my project return the object they just created, because it can contain other attributes or fix the submitted ones :
Activity
pyricau commentedon Aug 2, 2012
I think you're right. @a-thomas, what do you think ?
pyricau commentedon Aug 2, 2012
Also see http://stackoverflow.com/a/299696/703646
louishuh commentedon Aug 16, 2012
I hope this issue be assigned.
Thank you, Pyricau.
a-thomas commentedon Sep 4, 2012
Hi, sorry for the late reply.
I don't know any specific HTTP rules about PUT and DELETE response bodies. I think that you can return what you want. But, PUT and DELETE generally don't need to return anything. Indeed, an appropriate HTTP status code (200, 201...) is sufficient.
So, the question is : What do you want to return ?
Anyway, we initially implement the RestTemplate like the official Spring RestTemplate way. Let's see the 2.5.6 section of the documentation about PUT method. That explains what PUT and DELETE methods only return
void.louishuh commentedon Sep 6, 2012
Yeah... Spring's Resttemplate returns void for PUT&DELETE.
So, I use 'resttemplate.exchange(...)' method usually.
look at this url: https://jira.springsource.org/browse/SPR-7583
umm... I use for somthing additional information. It's difficult to explain.
Thank you, a-thomas
pyricau commentedon Sep 6, 2012
@a-thomas I think we use
exchangeanyway, right ? So we could actually implement this, am I correct ?royclarkson commentedon Sep 6, 2012
As @a-thomas said, PUT and DELETE don't normally require a response body, which is why we don't return anything in the
put()anddelete()convenience methods within RestTemplate. If a response body is desired, then using theexchange()method as @pyricau suggested, should give you what you need.a-thomas commentedon Sep 6, 2012
Yes indeed, we use the
exchange()method for flexibility reasons. In fact, the first one was the modification of the HTTP header fields.So, there is no problem for this implementation. Just doing like
@POSTand@GETmethods that they're already implemented.I just was interested in what @louishuh returned in their
@PUTand@DELETEmethods :)Anyway, I'll do it ASAP. Thanks @royclarkson for your reply ;)
mathieuboniface commentedon Nov 24, 2012
@a-thomas any update about this ?
rockytriton commentedon May 23, 2013
Where I work, all of our rest APIs have a request and response object attached, even PUT and DELETE. I agree that it should be supported.
JoanZapata commentedon May 24, 2013
@a-thomas I have a common use case (the 9-months late use case, ah ah)
How do you get this ID if you don't return anything ? You'd have to GET the whole list to retrieve the newly created one. Almost all POST methods in my project return the object they just created, because it can contain other attributes or fix the submitted ones :
➡️
{ name: "Hello" }⬅️
{ id: 1, creation_date: 1369376193, owner: "XXX", name: "HELLO" }DayS commentedon May 24, 2013
Seems legit :) We definitely have to implement this.
lalith-b commentedon Nov 20, 2013
The return type for put and delete annotations is handled and was merged in pull #748
DayS commentedon Nov 20, 2013
Nice catch. The wiki was already updated for this part. I changed milestone to 3.0.