Hii Anthony
I am able to POST and insert the data in to the database can you help me to
get the user email who will be authenticated and i will get the data from
the database which are associated with the particular user.
example:-
curl -u a...@gmail.com "http:127.0.0.1:8080/myapp/api/getdata/proj/id/1/acty"

I get the information of the proj by using his id by following code but how
i get the user information who are loged-in.

@auth.requires_login()
@request.restful()
def getdata():
    def GET(*args,**vars):
        patterns = "auto"
        parser = db.parse_as_rest(patterns,args,vars)
        if parser.status == 200:
            return dict(content=parser.response)
        else:
            raise HTTP(parser.status,parser.error)
return locals()



On Wed, May 30, 2012 at 9:51 AM, Sanjeet Roy <sanjeet.ro...@gmail.com>wrote:

> Thanks Anthony now i got it and i am able to post the request by using the
> CURL
>
>
> On Wed, May 30, 2012 at 8:23 AM, Anthony <abasta...@gmail.com> wrote:
>
>> If you want to make a POST 
>> request<http://en.wikipedia.org/wiki/POST_%28HTTP%29>,
>> you need some way to send the post data from a client. The client could be
>> a browser, in which case you can send post data by submitting a form or by
>> sending an Ajax POST request. The client could be another server, in which
>> case, you can use something like urllib2.urlopen() in Python (
>> http://docs.python.org/library/urllib2.html) or the Linux curlcommand-line 
>> utility (
>> http://www.yilmazhuseyin.com/blog/dev/curl-tutorial-examples-usage/).
>> You cannot make a POST request by simply visiting a URL in a browser --
>> that will only result in a GET request.
>>
>> What exactly are you trying to do? How are you intending to make requests
>> to this API?
>>
>> Anthony
>>
>>
>> On Tuesday, May 29, 2012 10:29:06 PM UTC-4, Sanjeet Roy wrote:
>>>
>>> Hi Anthony actually i didn't get you i want ipost the data something
>>> like that which are given in the following link :-
>>>
>>> http://www.mail-archive.com/**web2py@googlegroups.com/**msg70275.html<http://www.mail-archive.com/web2py@googlegroups.com/msg70275.html>
>>>
>>> http://vimeo.com/21133657
>>>
>>> http://www.reddit.com/r/**programming/comments/g5hxq/**
>>> web2py_trunk_has_a_new_**restful_api_that_writes_db/**c1l2ykg<http://www.reddit.com/r/programming/comments/g5hxq/web2py_trunk_has_a_new_restful_api_that_writes_db/c1l2ykg>
>>>
>>>
>>> On Wed, May 30, 2012 at 1:09 AM, Anthony <abasta...@gmail.com> wrote:
>>>
>>>> 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/<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('**n**ame'),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(**own**
>>>>> er=owner,name=name,info=**info)
>>>>>     return locals()
>>>>>
>>>>
>>> How can i post and insert the data in to the table dog which are given
>>> above .
>>>
>>> like that :-
>>>
>>>  curl -i -d 
>>> "info=aInfo&name=aName&owner=**74"http://localhost:8000/**restful/api/manage_dog
>>>  <http://localhost:8000/restful/api/manage_dog>
>>>
>>>
>>> which are given in the above link.
>>>
>>>
>

Reply via email to