retrieving GET request (parameters; @service.json)

23 views
Skip to first unread message

Vlad

unread,
Aug 3, 2022, 3:27:11 PMAug 3
to web2py-users
If the following is exposed:

@service.json
def test(a, b):
....

it works just fine when I submit url?a=val1;b=val2

but when I submit a dictionary - {"a":"val1", "b":val2"} - I can't figure out how to catch the parameters in the function test()  - it gives an error that they are missing. 

I am not fully controlling the client that does the request - I am just giving this client url and the dictionary containing parameters. 

on the server side - i.e. in test() - how do I figure out what exactly the client is doing - how exactly the parameters are passed so that I could read and process them in test()? 

Dave S

unread,
Aug 5, 2022, 9:52:00 PMAug 5
to web2py-users
I get an "unexpected keyword argument" exception if I try to use the dictionary in the url.  The manual only describes 2 syntaxes:
  the test?a=val1&b=val2  version (note, '&' not ';'), and using test/val1/val2.

request.args is ['json', 'test'] for the first form, and ['json', 'test', 'val1', 'val2'] for the second.


/dps

Dave S

unread,
Aug 7, 2022, 1:34:58 AMAug 7
to web2py-users
request.vars <Storage {'a': 'val1', 'b': 'val2'}> and <Storage {}> respectively. 
Reply all
Reply to author
Forward
0 new messages