tags:

views:

748

answers:

2

I'm trying to figure out how to implement my first RESTful interface using Django and django-rest-interface. I'm having problems with the HTTP PUT requests.

How do I access the parameters of the PUT request? I thought they would be in the request.POST array, as PUT is somewhat similar to POST in my understanding, but that array is always empty.

What am I doing wrong?

Thanks for the help

+2  A: 

request.POST processes form-encoded data into a dictionary, which only makes sense for web browser form submissions. There is no equivalent for PUT, as web browsers don't PUT forms; the data submitted could have any content type. You'll need to get the raw data out of request.raw_post_data, possibly check the content type, and process it however makes sense for your application.

More information in this thread.

Carl Meyer
+2  A: 

if you figure in the dispatch of ResourceBase there are a line like:

elif request_method == 'PUT':
    load_put_and_files(request)
    return target.update(request, *args, **kwargs)

load_put_and_files let prepare for you the request.PUT with the data y the request.method is PUT, so you dont have to worry about that...