[web2py] Re: Rest Json

2017-01-08 Thread PK
On Saturday, January 7, 2017 at 9:45:15 PM UTC, 黄祥 wrote: > > pls try : > ### Change user with email if username is disabled > ### Check patterns in > http://127.0.0.1:8000/application/controller/api/patterns.json > > ## curl > # GET > curl -X GET --user user:password -i >

[web2py] Re: Rest Json

2017-01-07 Thread 黄祥
pls try : ### Change user with email if username is disabled ### Check patterns in http://127.0.0.1:8000/application/controller/api/patterns.json ## curl # GET curl -X GET --user user:password -i http://127.0.0.1:8000/application/controller/api/books.json # POST curl -X POST --user

[web2py] Re: Rest Json

2017-01-07 Thread PK
On Saturday, January 7, 2017 at 2:42:31 PM UTC, PK wrote: > > > > On Thursday, January 5, 2017 at 3:08:46 PM UTC, Leonel Câmara wrote: >> >> PK you need to tell the server you're posting JSON in content-type for >> instance using $.ajax >> >> var somedict = {a: 1, b: 2}; >> >> >> $.ajax({ >> >>

[web2py] Re: Rest Json

2017-01-07 Thread PK
On Thursday, January 5, 2017 at 3:08:46 PM UTC, Leonel Câmara wrote: > > PK you need to tell the server you're posting JSON in content-type for > instance using $.ajax > > var somedict = {a: 1, b: 2}; > > > $.ajax({ > > type: "POST", > url: "{{=URL()}}", > dataType: "json", /* if

[web2py] Re: Rest Json

2017-01-05 Thread Leonel Câmara
PK you need to tell the server you're posting JSON in content-type for instance using $.ajax var somedict = {a: 1, b: 2}; $.ajax({ type: "POST", url: "{{=URL()}}", dataType: "json", /* if the server is also replying with json*/ contentType: "application/json;

[web2py] Re: Rest Json

2017-01-04 Thread PK
On Wednesday, January 4, 2017 at 10:04:31 PM UTC, Anthony wrote: > > On Wednesday, January 4, 2017 at 4:42:28 PM UTC-5, 黄祥 wrote: >> >> with >> return response.json(list_of_records) >> >> it return a json format even we request it with *.xml >> curl http://127.0.0.1:8000/a/default/api/test.xml

[web2py] Re: Rest Json

2017-01-04 Thread Anthony
On Wednesday, January 4, 2017 at 4:42:28 PM UTC-5, 黄祥 wrote: > > with > return response.json(list_of_records) > > it return a json format even we request it with *.xml > curl http://127.0.0.1:8000/a/default/api/test.xml > is there a way to have it both json or xml without content variable? > You

[web2py] Re: Rest Json

2017-01-04 Thread 黄祥
with return response.json(list_of_records) it return a json format even we request it with *.xml curl http://127.0.0.1:8000/a/default/api/test.xml is there a way to have it both json or xml without content variable? best regards, stifan -- Resources: - http://web2py.com -

[web2py] Re: Rest Json

2017-01-04 Thread PK
On Wednesday, January 4, 2017 at 4:21:35 PM UTC, Anthony wrote: > > Presumably you are relying on the generic.json view. Note, the only way > for a view to be triggered is for the controller to return a dictionary, > but of course that means the generic.json view will be converting a >

[web2py] Re: Rest Json

2017-01-04 Thread Anthony
Presumably you are relying on the generic.json view. Note, the only way for a view to be triggered is for the controller to return a dictionary, but of course that means the generic.json view will be converting a dictionary to JSON -- there is no way to have it receive and convert a list to

[web2py] Re: Rest Json

2017-01-04 Thread 黄祥
tryin to help but no clue, hehe *python console work as expected* >>> d = {"content": [{"a": "1", "b": "2", "c": "3"}]} >>> l = d.values() >>> l[0] [{'a': '1', 'c': '3', 'b': '2'}] *controllers/default.py* @request.restful() def api(): response.view = 'generic.' + request.extension def