Re: partial updates to same url?
mike amundsen <[email protected]>
| Newsgroups | gmane.comp.web.services.rest |
|---|---|
| Message-ID | <CAPW_8m43u_45eOmggUmg4pTUtaQ-eq04qC4RtyoLAVRLYmFm3A@mail.gmail.com> |
when i want to support partial updates on an existing resource and only
have POST at my disposal (i.e. brower-based clients) is usually do the
following:
- create an HTML.FORM (or other equiv in the preferred media type) that
contains
+ etag of existing resource
+ fields to update (usually pre-populated w/ existing data)
+ an URL that is unique for that resource (/blog-posts/{id};partial,
/partial-updates/{globally-unique-id}, etc.)
the etag serves to prevent:
- distributed update problem
- multi-post by the same client
the URL helps
- not confuse the original URL (/blog-posts/{id}) with the partial update
- allows me to get away with *not* using a PATCH-style message format
(again, helpful for browser-based cases)
- BTW - in one case i used the etag in the POST URL
(/blog-posts/{id};{etag}) but that was kinda messy due to encoding details
of course this means the caches are out-of-date, but using the ETag limits
that problem to only caches that don't honor the ETag.
Hope this gives you some ideas.
mca+1.859.757.1449
skype: mca.amundsen
http://amundsen.com/blog/
http://twitter.com/mamund
https://github.com/mamund
http://www.linkedin.com/in/mikeamundsen
On Sat, Oct 13, 2012 at 7:03 PM, Jan Algermissen <[email protected]
> wrote:
>
> On Oct 14, 2012, at 12:49 AM, Colin Taylor wrote:
>
> > Hi, I need to do a partial update so I'm POSTing with Etag of whole
> resource as precondition, i.e I'm POSTing to same URL as the resource. It
> feels like I should be doing it to a sub URL though, but how do I reconcile
> that with sending the Etag?
>
> Interesting question.
>
> I am not sure POST goes with Conditional update. Need to check the spec.
>
> Meanwhile - can you use PATCH?
>
> You'd need to roll your own little patch media type. Would be interesting
> if you shared your use case.
>
>
> PATCH /contract/42
> If-Match: "3"
> Content-Type: application/contract-update
>
> <contract-update>
> <set-status>platinum</set-status>
> </contract-update>
>
> 200 Ok
> ETag: "4"
> Content-Type: application/contract
>
> <contract>
> <name>Bert</name>
> <status>platinum</status>
> </contract>
>
> Jan
>
> >
> >
> > cheers
> > Colin
> >
> >
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>