You should not be posting JSON strings to the webserver. The 'post_vars' 
can contain anything that json itself can represent, and it is more 
efficient. If you do a post of a json string with $.POST it will convert 
that json string to http variables because that's what you should be doing.

On Wednesday, July 31, 2013 11:53:09 PM UTC-7, Ray (a.k.a. Iceberg) wrote:
>
> To whom it may concern:
>
> I tried posting vars in json format, with content-type: application/json 
> header, to my web2py application.
>
> When the above test is run on my laptop, i.e. requests are sent directly 
> to web2py's rocket web server, recent web2py (the 2.5.1-stable) can 
> successfully decode the payload into request.vars, as expected as mentioned 
> in https://groups.google.com/d/msg/web2py/9YdxVpuJlA8/ek0zJae5U9YJ
>
> But when I deploy my application to my production server, the same web2py 
> 2.5.1-stable can not recognize the payload and the request.vars are always 
> empty. How come?
>
> My production server is running a web2py (was 2.4.6, and then manually 
> overwritten by those files in 2.5.1's web2py_src.zip), behind apache's 
> mod_wsgi, (which itself is behind a global nginx, but that architecture is 
> a webfaction convention which I think is not relevent).
>
> Below is the request full content:
>
> *POST /examples/simple_examples/status/foo/bar.json HTTP/1.1*content-type: 
> application/jsonHost: example.comContent-Length:14user-agent: fake
> Connection:Keep-Alive
>
>
> {"foo": "bar"}
>
>
> And below is part of the web2py response, showing the request content. You 
> can see web2py got the correct content type header, but still fail to decode 
> the json payload in request.
>
> env:
>
>
>
>
>
>
> content_length:
> 14
> content_type:
> application/json
> http_connection:
> close
> http_forwarded_request_uri:
> /examples/simple_examples/status/foo/bar.json
> http_host:
> sandbox.xxxxxxxx.com
> http_http_x_forwarded_proto:
> http
> http_https:
> off
> http_user_agent:
> fake
> http_x_forwarded_for:
> 107.23.xxx.xxx
> http_x_forwarded_host:
> sandbox.xxxxxxxx.com
> http_x_forwarded_proto:
> http
> http_x_forwarded_server:
> sandbox.xxxxxxxx.com
> http_x_forwarded_ssl:
> off
>
>
> post_vars:
>
> vars:
>
> wsgi:
> environ:
> CONTENT_LENGTH:
> 14
> CONTENT_TYPE:
> application/json
>
>
>
>
>
>

-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to