Bad Request Http body is incomplete

560 views
Skip to first unread message

António Ramos

unread,
Oct 1, 2013, 9:47:30 AM10/1/13
to web...@googlegroups.com
hello i have a user trying to create a record.
When he submits he gets a blank page saying

Bad Request Http body is incomplete


What is this?

I dont have any ticket in my admin.


Thank you
António

Anthony

unread,
Oct 1, 2013, 10:08:20 AM10/1/13
to web...@googlegroups.com
Hard to say without seeing any code.

Niphlod

unread,
Oct 1, 2013, 11:24:16 AM10/1/13
to web...@googlegroups.com
usually that turns out when there is no content-length header in the POST 

Sebastián Tromer

unread,
Oct 2, 2013, 2:40:57 PM10/2/13
to web...@googlegroups.com
Hey, I was running into the same problem. I hope this can solve your problem...

I'm developing a RESTful API to add new resources (records in DB)
I'm exposing the API using this code in my default.py controller:

@request.restful()
def api():
    rest = module_api.RESTful(db, auth.user_id)
   
def POST(*args, **vars):
        
try:
            return rest.process_post(*args, **vars)
        except module_api.Error as e:
            raise HTTP(e.code)
   
return dict(POST=POST)

As you can see my POST request are processed by a function called process_post inside a module called module_api
I'm passing *args and **vars to process_post.

When I have your problem I was using an aux function inside my process_post function like this:

def process_post(*args, **vars):
   
# Aux function to map from args passed in the URL to real db resource
   
def map_resource(*args, **vars):
       
# some code

   
# some code calling map_resource(*args, **vars)...

Every POST I made resulted in:

raise HTTP(400, "Bad Request - HTTP body is incomplete") in line 252 form gluon/globals.py

Then I changed my code to something like:

def process_post(*args, **vars):
   
# Aux function to map from args passed in the URL to real db resource
   
def map_resource():
       
# some code using *args and **vars from process_post

   
# some code calling map_resource()...

I don't know if your are running into the same problem, but this solved my problem.

Greets!
Sebastián Tromer. 

António Ramos

unread,
Oct 2, 2013, 4:56:40 PM10/2/13
to web...@googlegroups.com
Thank you for your time.
Its nothing like what i have.

In my case my form is saved correctly.
It happened to one user only and i dont know if he still has the same problem.

Tomorrow i will check again

Thank you



2013/10/2 Sebastián Tromer <tromers...@gmail.com>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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 web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages