Are 4 Verbs Enough
Question for Mark Baker:
Suppose I have a resource which is an ordered list of other resources. What’s a suitable protocol to swap two elements around?
What happens if the list is 1,500 elements?
Can we do this with GET, PUT, POST or DELETE?
Thanks!
Update for other readers: Thanks to Mark, I learnt something new today. Stefan Tilkov had a link to HTTP PATCH RFC but that appears to be dead. There’s an expired version of the HTTP PATCH RFC over at Greenbytes.
I’m not entirely satisfied with the outcome though. If we have to extend HTTP specs, I’d rather an extension be provided so that multiple resource operations can be expressed over a single HTTP call / transaction. Server operations are always going to be hard to express, regardless of whether one uses SOAP or REST style APIs. WebDAV operations is an example. Life gets tricky, quickly.
How about specifying a minimal set of composable OPCODEs that a server can implement? This is kind of a compromise between REST and SOAP. At least then we end up with a pattern that every one can speak?
May 17th, 2006 at 1:40 pm
It seems that if you’re using a good representation for your resources then it’d be trivial to do this operation with a POST, which I believe would be the correct verb here since it’s an update.
Assume we have:
1. …
2. …
3. http://localhost/some/thing
4. http://localhost/some/other/thing
5. …
6. …
And then update by just POSTing the data that’s needs changing:
POST
http://localhost/some/thing
http://localhost/some/other/thing
That seems like the cleanest way to me and it scales to arbitrarily large lists. I generally think of POST as an update operation and usually as a partial one at that.
May 17th, 2006 at 1:41 pm
oops, there was fancy XML in the POSTed data but it has been lost.
May 17th, 2006 at 6:06 pm
PUT with ranges? Or break the resource up into chunks and PUT to a chunk - basically doing ranges one level up.
May 18th, 2006 at 8:27 am
Interesting. PUT with ranges will require normalized XML.
It would have been nice to be able to do chunked HTTP PUT, similar to multipart mime post, but to different URLs. Then we can express the swap in one transaction.
Mark, did you read the ACM Queue interview with Amazon CTO who said the REST camp was just being vocal, …. people just wanted things to work, and not fuss over what goes over the wire?
May 18th, 2006 at 9:47 pm
BTW, PATCH would also be useful for that.
Yah, I read Werner’s interview. He’s a brilliant guy, but he just doesn’t understand the Web.