[web2py] Re: call to PUT restapi from angular

2018-03-14 Thread Leonel Câmara
That said, a simple solution is simply to use POST instead of PUT. -- 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 a

[web2py] Re: call to PUT restapi from angular

2018-03-14 Thread Leonel Câmara
Humm arguably this could be supported by web2py then. It would be easy for the restful decorator to automatically provide an OPTIONS handler. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web

Re: [web2py] Re: call to PUT restapi from angular

2018-03-13 Thread Dave S
On Tuesday, March 13, 2018 at 9:25:44 PM UTC-7, yogeshwar khalkar wrote: > > Hi Leonel, > > print request.env.request_method > > prints - "OPTIONS" > > Thanks, > Yogeshwar > > Ah, the Angular library is doing a two-step. OPTIONS is a request for the supported (HTTP) verbs. I'm kind of surpri

Re: [web2py] Re: call to PUT restapi from angular

2018-03-13 Thread yogeshwar khalkar
Hi Leonel, print request.env.request_method prints - "OPTIONS" Thanks, Yogeshwar On Wed, Mar 14, 2018 at 2:19 AM, Val K wrote: > And keep in mind that 'return locals()' should be related to updateAgenda, > not PUT + I think it should be PUT(id, **kw) because you pass additional > payload, ot

[web2py] Re: call to PUT restapi from angular

2018-03-13 Thread Val K
And keep in mind that 'return locals()' should be related to updateAgenda, not PUT + I think it should be PUT(id, **kw) because you pass additional payload, otherwise you'll get 'bad request' -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/

[web2py] Re: call to PUT restapi from angular

2018-03-13 Thread Leonel Câmara
I don't see how you can be getting that error if you're actually sending a PUT request (I can see how you could be getting other errors since for instance web2py parses json in the request and puts it in vars) Put something like print request.env.request_method In your first model and see what

Re: [web2py] Re: call to PUT restapi from angular

2018-03-13 Thread yogeshwar khalkar
Still don't work. It returns 405 method not found. On Mar 13, 2018 7:00 PM, "Leonel Câmara" wrote: > You're missing a return locals() > > > @request.restful() > def updateAgenda(): > > def PUT(id): > data = json(request.body.read()) > ret = db(db.agenda.id >

[web2py] Re: call to PUT restapi from angular

2018-03-13 Thread Leonel Câmara
You're missing a return locals() @request.restful() def updateAgenda(): def PUT(id): data = json(request.body.read()) ret = db(db.agenda.id == id]).update(**data)