This is correct: xml = request.body.read() # retrieve the raw POST data If WSGI finds the body it should post it there.
On Friday, 5 April 2013 16:34:42 UTC-5, Jes M wrote: > > Hi all: > > I'm trying to expose an "api" function for REST. This "api" function has > to receive POST requests with XML in the body. The content-type is > 'text/xml'. The code (inspired on > http://www.web2py.com/AlterEgo/default/show/197): > > def api(): > xml = request.body.read() # retrieve the raw POST data > > logger.debug("Message XML Content: %s" % xml ) > > if len(xml) == 0: > xml = '<?xml version="1.0" encoding="utf-8" ?><root>no post > data</root>' > raise HTTP(400) #malformed > else: > now = datetime.datetime.now() > date_time = now.strftime("%Y-%m-%d %H:%M:%S") > > db.messages.validate_and_insert(date_time=date_time,xmlcontent=XML(xml)) > > raise HTTP(200) #OK > > > When I test this code with curl (curl -H "Content-Type: text/xml" > --data-binary "@./message_example.xml" > http://localhost:8000/cosa/default/api) the code works in the right way. > But when tried on a production environment it fails. > > How can check that the incoming HTTP POST comes with a XML body? > I read something about web2py or wsgi does not fill the request.body in > some circunstances... I don't remember exactly them, may a codification > issue? > > Any clue to fix this? > > Thanks in advance, > > Jes > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

