ok. got it. usually in APIs you don't post an array, you post an object.
automatic parsing works only for objects, not for arrays.
On Friday, October 24, 2014 8:08:02 PM UTC+2, Henry Nguyen wrote:
>
> I'm on the latest version from the repo,
> 2.10.0-beta+timestamp.2014.10.16.15.58.50,
> though
I'm on the latest version from the repo,
2.10.0-beta+timestamp.2014.10.16.15.58.50,
though I had this issue on the mainline 2.9.11 as well.
Henry
On Friday, October 24, 2014 12:37:15 AM UTC-7, Niphlod wrote:
>
> what web2py version are you on ?
>
> On Friday, October 24, 2014 3:01:23 AM UTC+2,
what web2py version are you on ?
On Friday, October 24, 2014 3:01:23 AM UTC+2, Henry Nguyen wrote:
>
> Niphlod,
>
> That does not appear to be the case, either for request.restful() requests
> or regular controller requests. For example, consider this controller
> method:
>
> def test():
> l
Niphlod,
That does not appear to be the case, either for request.restful() requests
or regular controller requests. For example, consider this controller
method:
def test():
logger.debug(request.env.content_type)
logger.debug(request.post_vars)
logger.debug(request.body.read())
if the content-type of the POST request is application/json, "mylist" would
actually be yet parsed into request.post_vars (i.e. you can skip
body.read())
On Thursday, October 23, 2014 1:24:09 AM UTC+2, Henry Nguyen wrote:
>
> For posterity's sake, I was able to retrieve the array in the request
For posterity's sake, I was able to retrieve the array in the request body
by using:
import json
my_list = json.loads(request.body.read())
and then iterating through the list items just like any other list. This
was taken from http://web2py.com/books/default/chapter/29/04#request under
request
you have to code your own methods.
On Sunday, October 12, 2014 11:32:23 PM UTC+2, Henry Nguyen wrote:
>
> I have a function in my controller decorated with the @request.restful()
> decorator. I would like to be able to accept a JSON array of objects,
>
> [{"id": 1, "new_value": 1},{"id": 2, "new
7 matches
Mail list logo