I am currently developing a REST API using Flask, Flask-sqlalchemy and flask-restless.
I have a User model and a Category model. A user can have many categories and a category belongs to only one user (one-to-many relationship). The relationship is set up in the sqlalchemy model.
I am using flask-restless to create the api. For instance, I have the following line to create the User api:
manager.create_api('User', collection_name='users', methods=['GET','POST','PUT','DELETE'])
When I do a GET request or POST request on /api/users, everything works fine.
When I do a GET request on /api/users/3/categories, it works too.
However, I am not able to do a POST request on /api/users/3/categories and get
Status Code: 405 METHOD NOT ALLOWED , Allow: OPTIONS, HEAD, GET
Apparently, only OPTIONS, HEAD and GET requests are allowed but when creating the api, I did include POST.
Do you guys have any idea what the problem is? Or how to extend the api to allow for the POST method in flask-restless?
If you want to add new categories to an existing user you should send a PUT/PATCH request to:
with the request data looking like this: