Flask restful is doing GET instead of POST


I have a simple flask & flask_restful application built in python as shown:

from flask import Flask
from flask_restful import Api, Resource

app = Flask(__name__)
api = Api(app)

class Route(Resource):
    def post(self):
        return "Posted"

api.add_resource(Route, '/')

if __name__ == '__main__':

However, when I run this app and navigate towards the link, I get this message:

    "message": "The method is not allowed for the requested URL."

And my flask output looks like this:

 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 691-936-340
 * Running on (Press CTRL+C to quit) - - [11/Jun/2021 10:07:33] "GET / HTTP/1.1" 405 -

It appears my API is making a get call when it should be making a post. Any suggestions?


when you are navigating via browser it send GET request that’s why you get
{"message": "The method is not allowed for the requested URL." }
i Tried send POST request Via Postman and it returned Valid Response.

Answered By – Giorgi Imerlishvili

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published