<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://townx.org" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>townx - REST semantics - Comments</title>
 <link>http://townx.org/blog/elliot/rest-semantics</link>
 <description>Comments for &quot;REST semantics&quot;</description>
 <language>en</language>
<item>
 <title>Interesting. That seems to</title>
 <link>http://townx.org/blog/elliot/rest-semantics#comment-14554</link>
 <description>&lt;p&gt;Interesting. That seems to go against the grain of the definitions in the &lt;span class=&quot;caps&quot;&gt;RFC&lt;/span&gt;/RESTful web services. If you&#039;re putting a comment on a blog post, the &lt;span class=&quot;caps&quot;&gt;RFC &lt;/span&gt;seems to suggest you should use &lt;span class=&quot;caps&quot;&gt;POST&lt;/span&gt;: you won&#039;t know the &lt;span class=&quot;caps&quot;&gt;URI &lt;/span&gt;of the resulting comment resource, which is a child of the blog post. However, I think you&#039;re also correct, in that if you update your profile, you are making a change to a resource which already exists - your modifications end up on the resource you identified by &lt;span class=&quot;caps&quot;&gt;URI.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;I think my preference would be:&lt;/p&gt;


&lt;ul&gt;
&lt;li&gt;&lt;span class=&quot;caps&quot;&gt;POST &lt;/span&gt;if you don&#039;t know the &lt;span class=&quot;caps&quot;&gt;URI &lt;/span&gt;of the resource you are creating.&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;caps&quot;&gt;PUT &lt;/span&gt;if you do, or if you are directly modifying an existing resource (not appending child resources).&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;The difficulty, to my mind, comes from creating children of existing resources: I think this should use &lt;span class=&quot;caps&quot;&gt;POST, &lt;/span&gt;as the client doesn&#039;t specify the created child&#039;s &lt;span class=&quot;caps&quot;&gt;URI.&lt;/span&gt;&lt;/p&gt;</description>
 <pubDate>Mon, 26 Nov 2007 19:40:37 -0600</pubDate>
 <dc:creator>elliot</dc:creator>
 <guid isPermaLink="false">comment 14554 at http://townx.org</guid>
</item>
<item>
 <title>As In English...</title>
 <link>http://townx.org/blog/elliot/rest-semantics#comment-14553</link>
 <description>&lt;p&gt;I think about the verbs as what they mean in English:  When you &lt;span class=&quot;caps&quot;&gt;PUT &lt;/span&gt;something somewhere you know exactly where you are putting it.  So &lt;span class=&quot;caps&quot;&gt;PUT &lt;/span&gt;the comment on the third post (/posts/3.)&lt;/p&gt;

&lt;p&gt;A &lt;span class=&quot;caps&quot;&gt;POST &lt;/span&gt;is more of an application to a membership club.  You &lt;span class=&quot;caps&quot;&gt;POST &lt;/span&gt;a letter to them (/members) and they respond telling you when they&#039;ve &lt;span class=&quot;caps&quot;&gt;CREATE&lt;/span&gt;d your membership and what your member ID is (/members/42.)  If you then wanted to &lt;span class=&quot;caps&quot;&gt;UPDATE &lt;/span&gt;your member information, you would &lt;span class=&quot;caps&quot;&gt;PUT &lt;/span&gt;that information on your profile (/members/42.)&lt;/p&gt;</description>
 <pubDate>Sun, 25 Nov 2007 22:59:53 -0600</pubDate>
 <dc:creator>CptOatmeal</dc:creator>
 <guid isPermaLink="false">comment 14553 at http://townx.org</guid>
</item>
<item>
 <title>I agree, Dan. I didn&#039;t</title>
 <link>http://townx.org/blog/elliot/rest-semantics#comment-14552</link>
 <description>&lt;p&gt;I agree, Dan. I didn&#039;t realise the distinction until I looked at the &lt;span class=&quot;caps&quot;&gt;HTTP RFC &lt;/span&gt;and &lt;span class=&quot;caps&quot;&gt;REST&lt;/span&gt;ful Web Services. I&#039;m just getting to grips with &lt;span class=&quot;caps&quot;&gt;REST&lt;/span&gt;ful Rails, by the way, so doubtless will be putting up some blog posts about further misunderstandings and confusion :)&lt;/p&gt;</description>
 <pubDate>Sun, 25 Nov 2007 13:37:16 -0600</pubDate>
 <dc:creator>elliot</dc:creator>
 <guid isPermaLink="false">comment 14552 at http://townx.org</guid>
</item>
<item>
 <title>PUT vs. POST confusion</title>
 <link>http://townx.org/blog/elliot/rest-semantics#comment-14551</link>
 <description>&lt;p&gt;I would agree that the only difference between &lt;span class=&quot;caps&quot;&gt;POST &lt;/span&gt;and &lt;span class=&quot;caps&quot;&gt;PUT &lt;/span&gt;is whom decides the &lt;span class=&quot;caps&quot;&gt;URI &lt;/span&gt;of the new resource.  If it&#039;s &lt;span class=&quot;caps&quot;&gt;POST, &lt;/span&gt;then the server decides.  If it&#039;s &lt;span class=&quot;caps&quot;&gt;PUT &lt;/span&gt;then the client decides.&lt;/p&gt;

&lt;p&gt;I love Restful Rails, but I think its conventions can confuse developers.  The mapping of &lt;span class=&quot;caps&quot;&gt;POST &lt;/span&gt;to create and &lt;span class=&quot;caps&quot;&gt;PUT &lt;/span&gt;to update in the controllers hides the fact that &lt;span class=&quot;caps&quot;&gt;PUT &lt;/span&gt;can also be used to create resources too.&lt;/p&gt;</description>
 <pubDate>Sun, 25 Nov 2007 13:02:32 -0600</pubDate>
 <dc:creator>Dan Kubb</dc:creator>
 <guid isPermaLink="false">comment 14551 at http://townx.org</guid>
</item>
<item>
 <title>Thanks Sergio, I think that</title>
 <link>http://townx.org/blog/elliot/rest-semantics#comment-14544</link>
 <description>&lt;p&gt;Thanks Sergio, I think that captures it. I think my confusion came from the fact that a create action may specify the location of the resulting new resource and therefore require &lt;span class=&quot;caps&quot;&gt;PUT. &lt;/span&gt;(This is what happens in Amazon &lt;span class=&quot;caps&quot;&gt;S3, &lt;/span&gt;where the &lt;span class=&quot;caps&quot;&gt;URI &lt;/span&gt;is specified on creation of new buckets/objects, so you know exactly where they&#039;re going to be located.).&lt;/p&gt;</description>
 <pubDate>Sat, 24 Nov 2007 10:57:00 -0600</pubDate>
 <dc:creator>elliot</dc:creator>
 <guid isPermaLink="false">comment 14544 at http://townx.org</guid>
</item>
<item>
 <title>POST for Updates?</title>
 <link>http://townx.org/blog/elliot/rest-semantics#comment-14542</link>
 <description>&lt;p&gt;I think the textbook explanations are clear, but if you need another way to look at it, I like to think like this:&lt;br /&gt;
1 - If the data you are submitting is going to produce a new &lt;span class=&quot;caps&quot;&gt;URI, &lt;/span&gt;then it&#039;s a creation action: &lt;span class=&quot;caps&quot;&gt;POST&lt;/span&gt;&lt;br /&gt;
2 - If the data will live in an existing &lt;span class=&quot;caps&quot;&gt;URI, &lt;/span&gt;then you&#039;re just replacing the existing content at that &lt;span class=&quot;caps&quot;&gt;URI&lt;/span&gt;: &lt;span class=&quot;caps&quot;&gt;PUT&lt;/span&gt;&lt;/p&gt;</description>
 <pubDate>Sat, 24 Nov 2007 08:18:32 -0600</pubDate>
 <dc:creator>Sergio</dc:creator>
 <guid isPermaLink="false">comment 14542 at http://townx.org</guid>
</item>
<item>
 <title>POST for Updates?</title>
 <link>http://townx.org/blog/elliot/rest-semantics#comment-14541</link>
 <description>&lt;p&gt; &amp;gt; Update &lt;br /&gt;
 &amp;gt;   - If you are modifying a resource by overwriting existing data (e.g. replacing a blog entry with a new one), use &lt;span class=&quot;caps&quot;&gt;PUT.&lt;/span&gt;&lt;br /&gt;
 &amp;gt;   - If you are appending new data to an existing resource (e.g. adding a comment to a blog entry), use &lt;span class=&quot;caps&quot;&gt;POST.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;If you are appending new data, you are effectively creating a new resource. Therefore it is quite natural to use &lt;span class=&quot;caps&quot;&gt;POST..&lt;/span&gt;&lt;/p&gt;</description>
 <pubDate>Sat, 24 Nov 2007 05:32:52 -0600</pubDate>
 <dc:creator>luniki</dc:creator>
 <guid isPermaLink="false">comment 14541 at http://townx.org</guid>
</item>
<item>
 <title>REST semantics</title>
 <link>http://townx.org/blog/elliot/rest-semantics</link>
 <description>&lt;p&gt;As part of my work at &lt;a href=&quot;http://talis.com/&quot;&gt;Talis&lt;/a&gt;, I&#039;m currently working on a &lt;span class=&quot;caps&quot;&gt;REST&lt;/span&gt;ful application (for library data). I&#039;ve read the &lt;a href=&quot;http://www.amazon.co.uk/dp/0596529260&quot;&gt;&lt;span class=&quot;caps&quot;&gt;REST&lt;/span&gt;ful Web Services&lt;/a&gt; book, I know about &lt;span class=&quot;caps&quot;&gt;REST&lt;/span&gt;ful Rails, I&#039;m aware of the &lt;a href=&quot;http://bitworking.org/projects/atom/draft-ietf-atompub-protocol-17.html&quot; title=&quot;APP&quot;&gt;Atom Publishing Protocol&lt;/a&gt;, and I&#039;ve done &lt;a href=&quot;http://s33r.rubyforge.org/&quot;&gt;some work&lt;/a&gt; with the &lt;a href=&quot;http://aws.amazon.com/s3&quot;&gt;Amazon S3&lt;/a&gt; interface. But so far I can&#039;t find a complete agreement on the exact semantics of &lt;span class=&quot;caps&quot;&gt;POST &lt;/span&gt;vs. &lt;span class=&quot;caps&quot;&gt;PUT.&lt;/span&gt; Which one maps onto resource creation, and which one onto update? The frameworks I mentioned above aren&#039;t in complete agreement:&lt;/p&gt;


&lt;ul&gt;
&lt;li&gt;In the &lt;span class=&quot;caps&quot;&gt;REST&lt;/span&gt;ful Web Services book, it&#039;s complicated. &lt;span class=&quot;caps&quot;&gt;POST &lt;/span&gt;is used to append new resources to an existing resource (creating child resources, effectively), and &lt;span class=&quot;caps&quot;&gt;PUT &lt;/span&gt;used to create new resources where the client knows the &lt;span class=&quot;caps&quot;&gt;URI &lt;/span&gt;of the new resource (see S3 below). &quot;The difference between &lt;span class=&quot;caps&quot;&gt;PUT &lt;/span&gt;and &lt;span class=&quot;caps&quot;&gt;POST&lt;/span&gt;&lt;br /&gt;
is this: the client uses &lt;span class=&quot;caps&quot;&gt;PUT &lt;/span&gt;when it’s in charge of deciding which &lt;span class=&quot;caps&quot;&gt;URI &lt;/span&gt;the new resource&lt;br /&gt;
should have. The client uses &lt;span class=&quot;caps&quot;&gt;POST &lt;/span&gt;when the server is in charge of deciding which &lt;span class=&quot;caps&quot;&gt;URI&lt;/span&gt;&lt;br /&gt;
the new resource should have.&quot;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;caps&quot;&gt;APP &lt;/span&gt;specifies that a &lt;span class=&quot;caps&quot;&gt;POST &lt;/span&gt;= create, and &lt;span class=&quot;caps&quot;&gt;PUT &lt;/span&gt;= update.&lt;/li&gt;
&lt;li&gt;In Rails, &lt;span class=&quot;caps&quot;&gt;POST &lt;/span&gt;= create, &lt;span class=&quot;caps&quot;&gt;PUT &lt;/span&gt;= update.&lt;/li&gt;
&lt;li&gt;In &lt;span class=&quot;caps&quot;&gt;S3, PUT &lt;/span&gt;= create (there are no updates, just overwrites).&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;I think it boils down to:&lt;/p&gt;


&lt;ul&gt;
&lt;li&gt;Create
&lt;ul&gt;
&lt;li&gt;If you are placing a new resource into a known location identified by &lt;span class=&quot;caps&quot;&gt;URI, &lt;/span&gt;use &lt;span class=&quot;caps&quot;&gt;PUT &lt;/span&gt;(e.g. you are creating a new web page and know where you want to serve it once it is in place on the server).&lt;/li&gt;
&lt;li&gt;If you are creating a new resource and don&#039;t know where it will end up (its &lt;span class=&quot;caps&quot;&gt;URI&lt;/span&gt;) (e.g. creating a new blog entry), use &lt;span class=&quot;caps&quot;&gt;POST.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Update
&lt;ul&gt;
&lt;li&gt;If you are modifying a resource by overwriting existing data (e.g. replacing a blog entry with a new one), use &lt;span class=&quot;caps&quot;&gt;PUT.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;If you are appending new data to an existing resource (e.g. adding a comment to a blog entry), use &lt;span class=&quot;caps&quot;&gt;POST.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;I went back to &lt;a href=&quot;http://www.w3.org/Protocols/rfc2616/rfc2616.html&quot;&gt;&lt;span class=&quot;caps&quot;&gt;RFC&lt;/span&gt; 2616&lt;/a&gt; for the formal distinction between &lt;span class=&quot;caps&quot;&gt;POST &lt;/span&gt;and &lt;span class=&quot;caps&quot;&gt;PUT, &lt;/span&gt;which is defined as follows:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;&quot;The &lt;span class=&quot;caps&quot;&gt;POST &lt;/span&gt;method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line.&quot; (trans.: if you create a new resource &quot;inside&quot; an existing &lt;span class=&quot;caps&quot;&gt;URI, &lt;/span&gt;use &lt;span class=&quot;caps&quot;&gt;POST&lt;/span&gt;: this applies if you are doing something like creating a new resource and you don&#039;t know what its &lt;span class=&quot;caps&quot;&gt;URI &lt;/span&gt;will be).&lt;/p&gt;&lt;/blockquote&gt;

&lt;blockquote&gt;&lt;p&gt;&quot;The &lt;span class=&quot;caps&quot;&gt;PUT &lt;/span&gt;method requests that the enclosed entity be stored under the supplied Request-URI.&quot; (trans.: use &lt;span class=&quot;caps&quot;&gt;PUT &lt;/span&gt;if you know the &lt;span class=&quot;caps&quot;&gt;URI &lt;/span&gt;of the resource you are creating or modifying).&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;This ties with the definition given in one of the comments by Sergio (thanks). What&#039;s interesting about this is that creating a resource where you know the resulting &lt;span class=&quot;caps&quot;&gt;URI &lt;/span&gt;should use &lt;span class=&quot;caps&quot;&gt;PUT&lt;/span&gt;; a modification will generally use &lt;span class=&quot;caps&quot;&gt;PUT&lt;/span&gt;; and creating a resource where you don&#039;t know the resulting &lt;span class=&quot;caps&quot;&gt;URI &lt;/span&gt;for it should use &lt;span class=&quot;caps&quot;&gt;POST.&lt;/span&gt; The &lt;span class=&quot;caps&quot;&gt;REST&lt;/span&gt;ful Web Services book follows this line.&lt;/p&gt;

&lt;p&gt;Any other thoughts?&lt;/p&gt;</description>
 <comments>http://townx.org/blog/elliot/rest-semantics#comments</comments>
 <category domain="http://townx.org/tech">tech</category>
 <pubDate>Sat, 24 Nov 2007 02:26:49 -0600</pubDate>
 <dc:creator>elliot</dc:creator>
 <guid isPermaLink="false">688 at http://townx.org</guid>
</item>
</channel>
</rss>
