Repository navigation
@Put and @Delete annotations return type #275
Description
Activity
I think you're right. @a-thomas, what do you think ?
I hope this issue be assigned.
Thank you, Pyricau.
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.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
@a-thomas I think we use
exchangeanyway, right ? So we could actually implement this, am I correct ?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 ;)
@a-thomas any update about this ?
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.
@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 :
➡️
{ name: "Hello" }
⬅️{ id: 1, creation_date: 1369376193, owner: "XXX", name: "HELLO" }Seems legit :) We definitely have to implement this.
The return type for put and delete annotations is handled and was merged in pull #748
Nice catch. The wiki was already updated for this part. I changed milestone to 3.0.
Hi.
I'm happy to know this project.
It's really useful and exciting.
I have a question.
Why @put and @delete annotations are not supporting return type?
HTTP Protocol has rule about these body?
Actually, My api service responses with body.
So I really want to use these annotations with return type.
Sorry for my English. I'm learning it;;