I am testing an API using the POST method, it shows the status as “405 Method Not Allowed”. But, when I change the method to Get, it works fine (status becomes 200 ok). Also, the parameters I am providing in the request body are already tested on a different platform. Request if you could please help me with this error.
Thank you
As @danny-dainton mentioned, to best troubleshoot, please provide some documentation around the API you are using.
However, in general, following HTTP standards, a 405 response status code means “Method Not Allowed”. So literally, a POST method is not allowed for that url endpoint on the server, in question. The server explicitly denies a POST method to that endpoint.
Likely, its been implemented using a GET request, since you were able to see success there.
Could you elaborate more on what you are trying to do, is there a reason you need a POST request? If you are certain you need a POST request, chances are, you’re just using the wrong endpoint on the server.
Again, this can only be solved if you have proper documentation to show what methods are supported for each endpoint.
I to got the same error, I tried many ways but still not able to resolve the error. I update the flask 1.1.2 even though no use. And try to remove the cookies, change the postman SSL setting still no use.
I’ve just encountered the same problem. The POST requests which worked fine in POSTMAN 2 weeks ago are failing with 405 “Method not allowed”. If I take the cURL line generated by POSTMAN and execute it on my PC everything is OK. The POST requests work in POSTMAN for my other API, but the first one fails with POSTMAN and works with cURL POST request generated by POSTMAN.
Edit: Problem solved. An accidental space was somehow added at the end of the URL.
The challenge is about routing.
If you set a general route name like “Api/Items” for all the methods in your controller. For methods like PUT or POST. There has to be something that distinguishes the method from other methods in the controller. so your POST Method could have an ID specified in the Verb e.g [HttpPost("{id}") . Alternatively you may choose to name the route explicitly to differentiate it from other routes like “API/Items/GetById/{id}”