[web2py] Re: RESTful request args/vars with JSON array

2014-10-24 Thread Niphlod
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

[web2py] Re: RESTful request args/vars with JSON array

2014-10-24 Thread Henry Nguyen
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,

[web2py] Re: RESTful request args/vars with JSON array

2014-10-24 Thread Niphlod
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

[web2py] Re: RESTful request args/vars with JSON array

2014-10-23 Thread Henry Nguyen
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())

[web2py] Re: RESTful request args/vars with JSON array

2014-10-23 Thread Niphlod
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

[web2py] Re: RESTful request args/vars with JSON array

2014-10-22 Thread Henry Nguyen
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

[web2py] Re: RESTful request args/vars with JSON array

2014-10-13 Thread Niphlod
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