I m working on developing api and I ve read in some article that PUT shall be used for complete replacement.But while referring to some API docs,they don't use PUT anymore though they have used the same in their previous version and it was replaced by POST(/resources/id) or PATCH(for partial updation)? And I m confused whether to use PUT or I will go with POST? And curious to know about the difference in using POST and PUT for updation?
On Thu, Sep 13, 2012 at 9:43 AM, Indu <indu9...@gmail.com> wrote:
> Hi all,
> I m working on developing api and I ve read in some article that PUT
> shall be used for complete replacement.But while referring to some API
> docs,they don't use PUT anymore though they have used the same in their
> previous version and it was replaced by POST(/resources/id) or PATCH(for
> partial updation)? And I m confused whether to use PUT or I will go with
> POST? And curious to know about the difference in using POST and PUT for
> updation?
> Thanks for looking into this
> Thanks & Regards,
> Indu
> --
> You received this message because you are subscribed to the Google Groups
> "API Craft" group.
> To unsubscribe from this group, send email to
> api-craft+unsubscribe@googlegroups.com.
> Visit this group at http://groups.google.com/group/api-craft?hl=en.
Hi Indu, the answer is a bit tricky. First of all the URI must exist
before the request. Then you have several options:
a) If you want complete replacement of the state use PUT. It has the
big advantage of being idempotent. Do not use this for partial
updates.
b) If you want partial update use PATCH. Ensure to use a mime type
that has appropiate semantics (partial document, diff, ...). It isn't
idempotent, so you should use some mechanism to avoid problems with
duplicated request (if-match, etag). The problem is that it's only a
proposed standard, so most server don't understand it:
http://tools.ietf.org/html/rfc5789 c) The old way for partial updates is using POST instead PATCH. Not
standarized. Usually use the same practices that the ones used with
PATCH. It is good to add a header: "X-HTTP-Method-Override: PATCH" in
order to more modern server switch to PATCH semantics.
On Thu, Sep 13, 2012 at 4:43 PM, Indu <indu9...@gmail.com> wrote:
> Hi all,
> I m working on developing api and I ve read in some article that PUT
> shall be used for complete replacement.But while referring to some API
> docs,they don't use PUT anymore though they have used the same in their
> previous version and it was replaced by POST(/resources/id) or PATCH(for
> partial updation)? And I m confused whether to use PUT or I will go with
> POST? And curious to know about the difference in using POST and PUT for
> updation?
> Thanks for looking into this
> Thanks & Regards,
> Indu
> --
> You received this message because you are subscribed to the Google Groups
> "API Craft" group.
> To unsubscribe from this group, send email to
> api-craft+unsubscribe@googlegroups.com.
> Visit this group at http://groups.google.com/group/api-craft?hl=en.
But while I m using PUT for updating I m facing the following issue:
1. I m not able to send the parameters in the request body,is forcing me to send it in the query parameter. I m afraid is it safe to send the write operation's parameters in query string and also the content length may exceed the allowed size of the query string if I send a large data for updation. 2.And also tomcat is not retrieving the value if in request.getParameter while using PUT
So I need to know whether this issue has been faced? And also why am I getting so?
On Thursday, 13 September 2012 20:26:30 UTC+5:30, Enrique Amodeo wrote:
> Hi Indu, the answer is a bit tricky. First of all the URI must exist > before the request. Then you have several options: > a) If you want complete replacement of the state use PUT. It has the > big advantage of being idempotent. Do not use this for partial > updates. > b) If you want partial update use PATCH. Ensure to use a mime type > that has appropiate semantics (partial document, diff, ...). It isn't > idempotent, so you should use some mechanism to avoid problems with > duplicated request (if-match, etag). The problem is that it's only a > proposed standard, so most server don't understand it: > http://tools.ietf.org/html/rfc5789 > c) The old way for partial updates is using POST instead PATCH. Not > standarized. Usually use the same practices that the ones used with > PATCH. It is good to add a header: "X-HTTP-Method-Override: PATCH" in > order to more modern server switch to PATCH semantics.
> Cheers !
> On Thu, Sep 13, 2012 at 4:43 PM, Indu <indu...@gmail.com <javascript:>> > wrote: > > Hi all,
> > I m working on developing api and I ve read in some article that > PUT > > shall be used for complete replacement.But while referring to some API > > docs,they don't use PUT anymore though they have used the same in their > > previous version and it was replaced by POST(/resources/id) or PATCH(for > > partial updation)? And I m confused whether to use PUT or I will go with > > POST? And curious to know about the difference in using POST and PUT for > > updation?
> > Thanks for looking into this
> > Thanks & Regards, > > Indu
> > -- > > You received this message because you are subscribed to the Google > Groups > > "API Craft" group. > > To unsubscribe from this group, send email to > > api-craft+...@googlegroups.com <javascript:>. > > Visit this group at http://groups.google.com/group/api-craft?hl=en.
Hi Indu, the correct thing to do is to send the parameters inside the
request body, not in the URL. Probably request.getParameter will not
understand the body unless you encode them the same way you use in the
URL (use mime type "application/x-www-form-urlencoded").
I suggest you to use a JAX-RS implementation instead the plain servlet stack.
Cheers,
Enrique Amodeo
On Thu, Sep 13, 2012 at 5:08 PM, Indu <indu9...@gmail.com> wrote:
> Thanks Joyce and Enrique
> But while I m using PUT for updating I m facing the following
> issue:
> 1. I m not able to send the parameters in the request body,is
> forcing me to send it in the query parameter. I m afraid is it safe to send
> the write operation's parameters in query string and also the content length
> may exceed the allowed size of the query string if I send a large data for
> updation.
> 2.And also tomcat is not retrieving the value if in
> request.getParameter while using PUT
> So I need to know whether this issue has been faced? And also why
> am I getting so?
> Thanks and Regards
> Indu
> On Thursday, 13 September 2012 20:26:30 UTC+5:30, Enrique Amodeo wrote:
>> Hi Indu, the answer is a bit tricky. First of all the URI must exist
>> before the request. Then you have several options:
>> a) If you want complete replacement of the state use PUT. It has the
>> big advantage of being idempotent. Do not use this for partial
>> updates.
>> b) If you want partial update use PATCH. Ensure to use a mime type
>> that has appropiate semantics (partial document, diff, ...). It isn't
>> idempotent, so you should use some mechanism to avoid problems with
>> duplicated request (if-match, etag). The problem is that it's only a
>> proposed standard, so most server don't understand it:
>> http://tools.ietf.org/html/rfc5789 >> c) The old way for partial updates is using POST instead PATCH. Not
>> standarized. Usually use the same practices that the ones used with
>> PATCH. It is good to add a header: "X-HTTP-Method-Override: PATCH" in
>> order to more modern server switch to PATCH semantics.
>> Cheers !
>> On Thu, Sep 13, 2012 at 4:43 PM, Indu <indu...@gmail.com> wrote:
>> > Hi all,
>> > I m working on developing api and I ve read in some article that
>> > PUT
>> > shall be used for complete replacement.But while referring to some API
>> > docs,they don't use PUT anymore though they have used the same in their
>> > previous version and it was replaced by POST(/resources/id) or PATCH(for
>> > partial updation)? And I m confused whether to use PUT or I will go with
>> > POST? And curious to know about the difference in using POST and PUT for
>> > updation?
>> > Thanks for looking into this
>> > Thanks & Regards,
>> > Indu
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "API Craft" group.
>> > To unsubscribe from this group, send email to
>> > api-craft+...@googlegroups.com.
>> > Visit this group at http://groups.google.com/group/api-craft?hl=en.
> --
> You received this message because you are subscribed to the Google Groups
> "API Craft" group.
> To unsubscribe from this group, send email to
> api-craft+unsubscribe@googlegroups.com.
> Visit this group at http://groups.google.com/group/api-craft?hl=en.
On Thursday, 13 September 2012 21:10:57 UTC+5:30, Enrique Amodeo wrote:
> Hi Indu, the correct thing to do is to send the parameters inside the > request body, not in the URL. Probably request.getParameter will not > understand the body unless you encode them the same way you use in the > URL (use mime type "application/x-www-form-urlencoded"). > I suggest you to use a JAX-RS implementation instead the plain servlet > stack. > Cheers, > Enrique Amodeo
> On Thu, Sep 13, 2012 at 5:08 PM, Indu <indu...@gmail.com <javascript:>> > wrote: > > Thanks Joyce and Enrique
> > But while I m using PUT for updating I m facing the following > > issue:
> > 1. I m not able to send the parameters in the request body,is > > forcing me to send it in the query parameter. I m afraid is it safe to > send > > the write operation's parameters in query string and also the content > length > > may exceed the allowed size of the query string if I send a large data > for > > updation. > > 2.And also tomcat is not retrieving the value if in > > request.getParameter while using PUT
> > So I need to know whether this issue has been faced? And also > why > > am I getting so?
> > Thanks and Regards > > Indu
> > On Thursday, 13 September 2012 20:26:30 UTC+5:30, Enrique Amodeo wrote:
> >> Hi Indu, the answer is a bit tricky. First of all the URI must exist > >> before the request. Then you have several options: > >> a) If you want complete replacement of the state use PUT. It has the > >> big advantage of being idempotent. Do not use this for partial > >> updates. > >> b) If you want partial update use PATCH. Ensure to use a mime type > >> that has appropiate semantics (partial document, diff, ...). It isn't > >> idempotent, so you should use some mechanism to avoid problems with > >> duplicated request (if-match, etag). The problem is that it's only a > >> proposed standard, so most server don't understand it: > >> http://tools.ietf.org/html/rfc5789 > >> c) The old way for partial updates is using POST instead PATCH. Not > >> standarized. Usually use the same practices that the ones used with > >> PATCH. It is good to add a header: "X-HTTP-Method-Override: PATCH" in > >> order to more modern server switch to PATCH semantics.
> >> Cheers !
> >> On Thu, Sep 13, 2012 at 4:43 PM, Indu <indu...@gmail.com> wrote: > >> > Hi all,
> >> > I m working on developing api and I ve read in some article > that > >> > PUT > >> > shall be used for complete replacement.But while referring to some > API > >> > docs,they don't use PUT anymore though they have used the same in > their > >> > previous version and it was replaced by POST(/resources/id) or > PATCH(for > >> > partial updation)? And I m confused whether to use PUT or I will go > with > >> > POST? And curious to know about the difference in using POST and PUT > for > >> > updation?
> >> > Thanks for looking into this
> >> > Thanks & Regards, > >> > Indu
> >> > -- > >> > You received this message because you are subscribed to the Google > >> > Groups > >> > "API Craft" group. > >> > To unsubscribe from this group, send email to > >> > api-craft+...@googlegroups.com. > >> > Visit this group at http://groups.google.com/group/api-craft?hl=en.
> > -- > > You received this message because you are subscribed to the Google > Groups > > "API Craft" group. > > To unsubscribe from this group, send email to > > api-craft+...@googlegroups.com <javascript:>. > > Visit this group at http://groups.google.com/group/api-craft?hl=en.