POST Method not Allowed

18 views
Skip to first unread message

Madireddy Samuel Vijaykumar

unread,
Apr 5, 2010, 9:45:06 PM4/5/10
to is...@googlegroups.com
Hi,

I am trying to implement a small sample webservice. The GET method there are no issues. But when i try to implement a POST. I get a 405, saying that POST method is not allowed for this resource. Could someone help in this regard.

Sam

Yoan Blanc

unread,
Apr 6, 2010, 2:40:40 AM4/6/10
to is...@googlegroups.com
Can you post your code somewhere?

--
Yoan

2010/4/6 Madireddy Samuel Vijaykumar <mad....@gmail.com>:

> --
> You received this message because you are subscribed to the Google Groups
> "ish.io" group.
> To post to this group, send an email to is...@googlegroups.com.
> To unsubscribe from this group, send email to
> ishio+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/ishio?hl=en-GB.
>

SamG

unread,
Apr 6, 2010, 7:36:43 AM4/6/10
to ish.io
Sorry,

here is the code http://dpaste.de/iOJQ/

Sam

On Apr 6, 11:40 am, Yoan Blanc <yoan.bl...@gmail.com> wrote:
> Can you post your code somewhere?
>
> --
> Yoan
>

> 2010/4/6 Madireddy Samuel Vijaykumar <mad.vi...@gmail.com>:


>
> > Hi,
>
> > I am trying to implement a small sample webservice. The GET method there are
> > no issues. But when i try to implement a POST. I get a 405, saying that POST
> > method is not allowed for this resource. Could someone help in this regard.
>
> > Sam
>
> > --
> > You received this message because you are subscribed to the Google Groups

> > "ish.io" group.> To post to this group, send an email toi...@googlegroups.com.

SamG

unread,
Apr 6, 2010, 8:18:15 AM4/6/10
to ish.io
Well has it got something to do with this?

(restish)sam@csslabs-laptop-xubuntu:/sandbox/restish/lib/python2.6$
grep -inHR allowed * | grep -i methods
site-packages/Paste-1.7.3-py2.6.egg/paste/fileapp.py:57:
allowed_methods = ('GET', 'HEAD')

which allows on the 'GET' and 'HEAD' method?

Sam

On Apr 6, 4:36 pm, SamG <mad.vi...@gmail.com> wrote:
> Sorry,
>
> here is the codehttp://dpaste.de/iOJQ/


>
> Sam
>
> On Apr 6, 11:40 am, Yoan Blanc <yoan.bl...@gmail.com> wrote:
>
> > Can you post your code somewhere?
>
> > --
> > Yoan
>
> > 2010/4/6 Madireddy Samuel Vijaykumar <mad.vi...@gmail.com>:
>
> > > Hi,
>
> > > I am trying to implement a small sample webservice. The GET method there are
> > > no issues. But when i try to implement a POST. I get a 405, saying that POST
> > > method is not allowed for this resource. Could someone help in this regard.
>
> > > Sam
>
> > > --

> > > You received this message because you are subscribed to the Google Groups> > "ish.io" group.> To post to this group, send an emailt...@googlegroups.com.> > To unsubscribe from this group, send email to>ishio+un...@googlegroups.com.

SamG

unread,
Apr 6, 2010, 8:40:29 AM4/6/10
to ish.io
I added POST to the allowed_methods tuple. But when i do a POST
request i end up getting the following as the response.

<html>
<head>
<title>my001</title>
</head>
<body>
<h1>my001</h1>
<p>This is the default page for the my001 project.</p>
<p>The page is called index.html and is part of your application's
package,
my001, inside the public/ directory, i.e. my001/public/
index.html.</p>
<p>Any files you add to the public directory will be served in
preference
to your application's dynamic resources.</p>
<p>When you're ready simply delete index.html and your root
resource will
be returned for this URL instead.</p>
</body>
</html>

Instead of an expected xml.

Sam

On Apr 6, 5:18 pm, SamG <mad.vi...@gmail.com> wrote:
> Well has it got something to do with this?
>
> (restish)sam@csslabs-laptop-xubuntu:/sandbox/restish/lib/python2.6$
> grep -inHR allowed * | grep -i methods
> site-packages/Paste-1.7.3-py2.6.egg/paste/fileapp.py:57:
> allowed_methods = ('GET', 'HEAD')
>
> which allows on the 'GET' and 'HEAD' method?
>
> Sam
>
> On Apr 6, 4:36 pm, SamG <mad.vi...@gmail.com> wrote:
>
> > Sorry,
>
> > here is the codehttp://dpaste.de/iOJQ/
>
> > Sam
>
> > On Apr 6, 11:40 am, Yoan Blanc <yoan.bl...@gmail.com> wrote:
>
> > > Can you post your code somewhere?
>
> > > --
> > > Yoan
>
> > > 2010/4/6 Madireddy Samuel Vijaykumar <mad.vi...@gmail.com>:
>
> > > > Hi,
>
> > > > I am trying to implement a small sample webservice. The GET method there are
> > > > no issues. But when i try to implement a POST. I get a 405, saying that POST
> > > > method is not allowed for this resource. Could someone help in this regard.
>
> > > > Sam
>

> > > > --> > > You received this message because you are subscribed to the Google Groups> > "ish.io" group.> To post to this group, send anemail...@googlegroups.com.> > To unsubscribe from this group, send email to>ishio+un...@googlegroups.com.

SamG

unread,
Apr 6, 2010, 9:21:12 AM4/6/10
to ish.io
Well this very suprising.

I create another project, my002.

And did a get on http://127.0.0.1:8080/ using firefox AddOn
RESTClient.

And i got the following as the response

<html>
<head>
<title>my002</title>
</head>
<body>
<h1>my002</h1>
<p>This is the default page for the my002 project.</p>


<p>The page is called index.html and is part of your application's
package,

my002, inside the public/ directory, i.e. my002/public/


index.html.</p>
<p>Any files you add to the public directory will be served in
preference
to your application's dynamic resources.</p>
<p>When you're ready simply delete index.html and your root
resource will
be returned for this URL instead.</p>
</body>
</html>


But the response should be the <p>Hello from my002!</p> right?

I am using retish 0.10

Sam

> > > > > --> > > You received this message because you are subscribed to the Google Groups> > "ish.io" group.> To post to this group, sendanema...@googlegroups.com.> > To unsubscribe from this group, send email to>ishio+un...@googlegroups.com.

SamG

unread,
Apr 6, 2010, 10:10:09 AM4/6/10
to ish.io
Forgive me for this rants...

I finally figured out that you needs to delete the index.html and
"clear the cache" from your browser.

And i got GET working but still have issues with the POST, still get a
405. I did a basic app to test this....

import logging
from restish import http, resource
import EC2


log = logging.getLogger(__name__)


class Root(resource.Resource):
@resource.POST()
def html(self, request):
return http.ok([('Content-Type', 'text/html')],
"<p>Hello from my002!</p>")

On Apr 6, 6:21 pm, SamG <mad.vi...@gmail.com> wrote:
> Well this very suprising.
>
> I create another project, my002.
>

> And did a get onhttp://127.0.0.1:8080/using firefox AddOn

> > > > > > --> > > You received this message because you are subscribed to the Google Groups> > "ish.io" group.> To post to this group,sendanema...@googlegroups.com.> > To unsubscribe from this group, send email to>ishio+un...@googlegroups.com.

Yoan Blanc

unread,
Apr 6, 2010, 10:57:53 AM4/6/10
to is...@googlegroups.com
Yep, don't forget to delete that default file `public/index.html`

this works for me (besides the double @ coming from pastie itself):

http://pastie.org/905695

--
Yoan

2010/4/6 SamG <mad....@gmail.com>:

> To post to this group, send an email to is...@googlegroups.com.

Matt Goodall

unread,
Apr 9, 2010, 5:44:11 AM4/9/10
to is...@googlegroups.com
On 6 April 2010 15:10, SamG <mad....@gmail.com> wrote:
Forgive me for this rants...

I finally figured out that you needs to delete the index.html and
"clear the cache" from your browser.

Hi Sam, 

Firstly, sorry for delayed reply but I've just got back from a short holiday. Thanks to Yoan (as always) for helping.

Glad you got things sorted out in the end, sorry it wasn't more obvious what you needed to do.

The public/index.html only really exists so that *something* useful is displayed by default. Assuming you read the index.html content ;-) how can we make it clearer that index.html should be deleted to expose your root resource?

For instance, would it have helped if the generated root resource referenced the index.html file, e.g.:

class Root(resource.Resource):
    @resource.GET()
    def html(self, request):
        # Not seeing this? Delete example/public/index.html to expose this resource.
        return http.ok([('Content-Type', 'text/html')],
            "<p>Hello from example!</p>")

Or perhaps making index.html describe the project's structure more would be more useful?

Any feedback would be appreciated.

- Matt
 
To post to this group, send an email to is...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages