How to get raw data from request

934 views
Skip to first unread message

Daniel

unread,
May 2, 2011, 4:41:58 PM5/2/11
to cherrypy-users
Hello,

I'm building a REST application and one use case receives a PUT http
request. The body contains a JSON document. I can't find anyway to
access the raw data in the request directly. The data is not url
encoded as a name=value pair. It is just the JSON document.

How can I access the data directly?

By the way, I'm using this to decide whether to process GET or PUT:

if cherrypy.request.method == "GET":
# process GET
elif cherrypy.request.method == "PUT":
# process PUT

Daniel

unread,
May 2, 2011, 4:52:45 PM5/2/11
to cherrypy-users
I found my answer here:
http://docs.cherrypy.org/dev/refman/_cpreqbody.html

I ended up getting the raw data with this:
cherrypy.request.body.read()
Reply all
Reply to author
Forward
0 new messages