12

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

1
  • I presume you've tried request.PUT? Commented Feb 1, 2009 at 13:08

2 Answers 2

13

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.

Sign up to request clarification or add additional context in comments.

Comments

4

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...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.