All I get in the client is: Process finished with exit code 0 On Thursday, January 30, 2014 11:20:11 PM UTC+2, Anthony wrote: > > .validate_and_insert returns a response object with an .id attribute and > an .errors attribute. If the insert is successful, response.id has the id > of the inserted records, and if there are any validation errors, > response.errors is a dictionary of field names and error messages. You can > have your function conditionally return the new record ID (or some success > message) or a string summary of the errors. Then just check the content of > that return value from the client where you are making the API requests. > > Anthony > > On Thursday, January 30, 2014 2:29:02 PM UTC-5, Avi A wrote: >> >> what do you mean? How can I check it? >> >> >> On Thursday, January 30, 2014 8:39:56 PM UTC+2, Anthony wrote: >>> >>> What does .validate_and_insert return? >>> >>> On Thursday, January 30, 2014 1:11:18 PM UTC-5, Avi A wrote: >>>> >>>> Thank you very much. >>>> No errors now, but still not inserting. I'll give it some more tries >>>> and get back if required. >>>> thanks again. >>>> >>>> On Thursday, January 30, 2014 7:59:23 PM UTC+2, Anthony wrote: >>>>> >>>>> Your api() function should end with: >>>>> >>>>> return locals() >>>>> >>>>> locals() is a dictionary containing all the variables (including the >>>>> functions) defined in the local function scope. >>>>> >>>>> Note, this is why it helps to describe the exact error/failure. >>>>> Initially I hadn't noticed the missing locals() return, but seeing the >>>>> exception made it obvious. >>>>> >>>>> Anthony >>>>> >>>>> On Thursday, January 30, 2014 5:30:52 AM UTC-5, Avi A wrote: >>>>>> >>>>>> Hi, >>>>>> I am trying something like that: >>>>>> #on one local script instance: >>>>>> import requests >>>>>> >>>>>> test_params = {'api_key': 'api_key', 'test': 'test', 'f_platform': >>>>>> 'platform', 'f_device': 'device', 'f_steps': '10', >>>>>> 'f_matches':'7', 'f_missmatches': '3', 'f_missing': >>>>>> '0'} >>>>>> r = requests.post('http://127.0.0.1:8000/qatests/api', >>>>>> params=test_params) >>>>>> >>>>>> #and the api function: >>>>>> >>>>>> @request.restful() >>>>>> def api(): >>>>>> response.view = 'generic.'+request.extension >>>>>> def GET(search): >>>>>> pass >>>>>> clients = db(db.auth_user).select(db.auth_user.api_key) >>>>>> t = db.t_tests_results >>>>>> def POST(**post_params): >>>>>> for client in clients: >>>>>> if client.api_key == post_params.api_key: >>>>>> return t.validate_and_insert(post_params.test, >>>>>> post_params.f_platform, >>>>>> post_params.f_device, >>>>>> post_params.f_steps, >>>>>> post_params.f_matches, >>>>>> post_params.f_missmatches, >>>>>> post_params.f_missing) >>>>>> else: >>>>>> raise HTTP(400) >>>>>> >>>>>> It's not working... Any help? >>>>>> Thanks. >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>>
-- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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.