> def POST(table_name,**vars): > return dict(db[table_name].validate_and_insert(**vars)) >
Just to be more explicit (and not so dependent on the magic in the generic.json view), I would instead recommend: db[table_name].validate_and_insert(**vars).as_dict() def PUT(table_name,record_id,**vars): > return dict(db(db[table_name]._id==record_id).update(**vars)) > def DELETE(table_name,record_id): > return dict(db(db[table_name]._id==record_id).delete()) > return dict(GET=GET, POST=POST, PUT=PUT, DELETE=DELETE) > > Can do my get, then I try: > > curl -X PUT -d "datavalue=updated" http: > //localhost:8007/apitest/default/secapi/secrets/id/21 > invalid arguments > Note, your PUT and DELETE functions take table_name and record_id positional arguments, yet you have passed "secrets", "id", and "21" as positional arguments (via URL args). There is no need for the "id" URL arg with these two methods. The "id" arg is used with the GET request because that method is relying on the more generalized parse_as_rest functionality, which matches patterns and allows you to specify a field name in addition to a table name. Just change your URL to: http://localhost:8007/apitest/default/secapi/secrets/21 If you want the GET function to be more consistent (and limit it to filtering by id), then you could exclude "id" from the GET URLs and instead insert "id" into the args list before passing args to parse_as_rest. Anthony -- 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/d/optout.