Re: Link relation for adding a resource
mike amundsen <[email protected]>
| Newsgroups | gmane.comp.web.services.rest |
|---|---|
| Message-ID | <CAPW_8m6sEjWr-FAJyHrNLKF4rHnmmazu2KcH8KsTFApzt_pzFw@mail.gmail.com> |
There are multiple ways to communicate interaction semantics of a problem domain within a response: 1 - mapping via link decorator such as @rel, @id, @name, etc. (i.e. rel="create" === add) 2 - mapping via document element (i.e. <create href="..." ... /> === add) 3 - mapping via protocol method (i.e. POST === add) 4 - mapping via resource identifier or identifier segment (i.e. /..../?create === add) The first two possibilities offer the most flexibility and evolvability over time since the client binds problem domain specifics to the response details (deocrator/element) which may appear in any response sent over any protocol using any identifier. The second two possibilities offer the least flexibility and evolvability over time since these solutions lead clients to bind problem domain specifics to protocol-level details that are usually harder to change over time and provide less portability (i.e. new protocols or identifier schemes, etc.). mca http://amundsen.com/blog/ http://twitter.com@mamund http://mamund.com/foaf.rdf#me On Sat, Sep 1, 2012 at 8:44 AM, Jan Algermissen <[email protected]>wrote: > > On Aug 31, 2012, at 6:07 PM, Paul Cohen wrote: > > > Hi, > > > > I would like to define, in JSON, a link that provides a way to add a > > new resource to a collection of resources. > > HTTP POST has that semantic already, there is no need to use a link > relation for that. > > All you need to know is that some resource has collection semantics, so > you should tell the client that /photos is a collection rather than > focussing on the action. > > > E.g. tell the client that /photos/ is the 'photos collection' (you can use > a link rel for that, or, e.g. an AtomPub service document, or a specific > media type you design) and that's it. That POST is for adding items is > known from HTTP already. > > Jan > > > > I'm considering this: > > > > "link": { > > "href": "/photos/", > > "type": "image/tiff", > > "method": "POST", > > "rel": "new", > > "title": "Add new photo"} > > > > I'd appreciate any comments on the link representation above. In > > particular I'm interested in suggestions for the relation type - I use > > "new" above. I've seen "new" being used in similar cases but it's not > > an officially registered relation type here: > > > > * http://www.iana.org/assignments/link-relations/link-relations.xml > > > > * http://www.w3.org/TR/html401/types.html#h-6.12 > > > > * http://microformats.org/wiki/existing-rel-values > > > > And there's no registered relation type with new/add/append-like > > semantics. Well maybe "create-form" on the mircroformats page, but > > that doesn't really seem appropriate. > > > > /Paul > > > > -- > > Paul Cohen > > www.seibostudios.se > > mobile: +46 730 787 035 > > e-mail: [email protected] > > > > > > ------------------------------------ > > Yahoo! Groups Links > > > >