Issue #1265 resolved

inaccurate docs on creating RESTful API

tkoomzaaskz avatartkoomzaaskz created an issue

Hello, I'm a cherrypy beginner. I wanted to create a RESTful API basing on the songs example from the docs. It says:

GET
---
Represents the Read method in CRUD.

Add a new method to the file songs.py, called GET:

I followed this code (adding the def GET) and added it to songs.py and I was getting 405 Method not allowed:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/CherryPy-3.2.4-py2.7.egg/cherrypy/_cprequest.py", line 656, in respond
    response.body = self.handler()
  File "/usr/local/lib/python2.7/dist-packages/CherryPy-3.2.4-py2.7.egg/cherrypy/lib/encoding.py", line 188, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/CherryPy-3.2.4-py2.7.egg/cherrypy/_cperror.py", line 386, in __call__
    raise self
HTTPError: (405, None)

It started to work after I moved the GET function from module level to Songs class level. It's not critical, but the docs here are inaccurate in my opinion. It should be Add a new method to Songs class inside the file songs.py instead of Add a new method to the file songs.py.

Comments (5)

  1. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.