You could submit the post request via a form on the page, with the form's
action set to the get_person URL, or you could submit via Ajax, possibly
using jQuery.post() (see http://api.jquery.com/jQuery.post/).
Anthony
On Tuesday, May 29, 2012 3:01:09 PM UTC-4, Sanjeet Roy wrote:
>
> Hii Anthony i have the following in my db:-
>
> db.define_table('person',Field('name'),Field('birthdate','date'))
>
> db.define_table('dog',Field('name'),Field('owner',db.person),Field('info','text'))
>
> and api.py is my controller :-
>
> @request.restful()
> def get_person():
> def GET(id):
> person = db.person(id)
> return person.as_dict() if person else None
> def POST(owner,name,info):
> return db.dog.validate_and_insert(owner=owner,name=name,info=info)
> return locals()
>
> i want to make the POST request to insert the data in database (by using
> the browser).
>
> On Wed, May 30, 2012 at 12:13 AM, Anthony <[email protected]> wrote:
>
>> Passing the variables in the URL is a GET request. How is the API being
>> called (e.g., from the browser, from a Python/web2py app, from another
>> server-side technology)? Depending on the answer, there are different ways
>> of making a POST request (e.g., from the browser, it could be via form
>> submission or an Ajax POST request, possibly using jQuery).
>>
>> Anthony
>>
>>
>> On Tuesday, May 29, 2012 2:35:07 PM UTC-4, Sanjeet Roy wrote:
>>>
>>> i am using the following controller can any one tell me how to pass the
>>> value in URL to insert the data in database i am trying :
>>>
>>> http://127.0.0.1:8000/myapp/**api/get_person/?owner=sanjeet&**
>>> name=roy&info=bangalore<http://127.0.0.1:8000/myapp/api/get_person/?owner=sanjeet&name=roy&info=bangalore>
>>>
>>> it gives the invalid argument can anyone tell me how i pass the valid
>>> argument to insert in database
>>>
>>>
>>>
>>> @request.restful()
>>> def get_person():
>>> def GET(id):
>>> person = db.person(id)
>>> return person.as_dict() if person else None
>>> def POST(owner,name,info):
>>> return db.dog.validate_and_insert(**owner=owner,name=name,info=*
>>> *info)
>>> return locals()
>>>
>>
>