Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Rest Template Put method is void, why?

Im using Spring Rest Template for Android, and am going to use the PUT method to update an method. But surprisingly the PUT methods ofter doesnt support parsing the result object, they are just void, how come? My understanding of proper REST support is that the updated object should be returned. Whats the rational from Spring`s side to do it like this?

2.5.6 HTTP PUT

public void put(String url, Object request, Object... urlVariables) throws RestClientException;

public void put(String url, Object request, Map<String, ?> urlVariables) throws RestClientException;

public void put(String url, Object request, Map<String, ?> urlVariables) throws RestClientException;

http://docs.spring.io/spring-android/docs/1.0.2.BUILD-SNAPSHOT/reference/html/rest-template.html

like image 785
Thomas Vervik Avatar asked Nov 02 '22 02:11

Thomas Vervik


1 Answers

PUT is analogous to updating an existing record on the server and so if you update something successfuly, you should inherently know the new state, as you changed it to that state.

That is, if you retrieve a document with a GET, the you have the server-side representation. If you then change one or more of the properties of that document, then PUT those changes to the server, you don't need to be told what the docment has changed to as you have the changed value already, presuming that the server returns a success response.

like image 113
pmckeown Avatar answered Nov 12 '22 18:11

pmckeown