Re: How to get a PUT request to work?

4 views
Skip to first unread message

corsair moran

unread,
Mar 21, 2009, 7:47:49 AM3/21/09
to Django REST interface
Hi,

I figured it out! I need to specify the pk in the url for both PUT and
DELETE. Additionally for PUT, I need to specify the desired changes as
xml in the content of the request.

Awesome! (Though I wonder what would i do for bulk updates and deletes?)

Thanks.

On 3/21/09, chefsmart <moran....@gmail.com> wrote:
> Hi,
>
> I have been using django_restapi with good results for reading and
> creating data. I have been trying to do updates via HTTP PUT, but the
> following is returned whenever I do a PUT request:
>
> <?xml version="1.0" encoding="utf-8"?>
> <django-error><error-message>404 NOT
> FOUND</error-message><status-code>404</status-code></django-error>
>
> I have tried going through the code to figure out why this is
> happening, with no luck. My restapi collection has permitted_methods =
> ('GET', 'POST', 'PUT',) and I am using properly formed xml in the
> content of the PUT request, which has a proper pk attribute of an
> existing object.
>
> Could someone please help me with this?
>
> Thanks and regards,
> C. Moran

chefsmart

unread,
Mar 21, 2009, 5:48:59 AM3/21/09
to Django REST interface

Jared Flatow

unread,
Mar 21, 2009, 1:07:05 PM3/21/09
to django-res...@googlegroups.com
Hi Corsair,

May I suggest reading up a little on the design of ReSTful web
services? The "ReSTful" way to delete resources "in bulk", is to
DELETE the collection resource containing those other resources.
Similarly a PUT to a collection might be allowed to update the whole
thing (i.e. replace it with the specified resources). It sounds like
before you were actually trying to do things with the collection
resource instead of the resource you were interested in (the one in
the collection with pk=your_pk).

jared

chefsmart

unread,
Mar 21, 2009, 2:55:41 PM3/21/09
to Django REST interface
Yes Jared, my background knowledge of ReSTful web services is
scratchy, I have recently bought an O'Reilly book on the subject and
really do need to get away from the computer and actually read it.

On Mar 21, 10:07 pm, Jared Flatow <jfla...@gmail.com> wrote:
> Hi Corsair,
>
> May I suggest reading up a little on the design of ReSTful web  
> services? The "ReSTful" way to delete resources "in bulk", is to  
> DELETE the collection resource containing those other resources.  
> Similarly a PUT to a collection might be allowed to update the whole  
> thing (i.e. replace it with the specified resources). It sounds like  
> before you were actually trying to do things with the collection  
> resource instead of the resource you were interested in (the one in  
> the collection with pk=your_pk).
>
> jared
>
> On Mar 21, 2009, at 6:47 AM, corsair moran wrote:
>
>
>
> > Hi,
>
> > I figured it out! I need to specify the pk in the url for both PUT and
> > DELETE. Additionally for PUT, I need to specify the desired changes as
> > xml in the content of the request.
>
> > Awesome! (Though I wonder what would i do for bulk updates and  
> > deletes?)
>
> > Thanks.
>
Reply all
Reply to author
Forward
0 new messages