405 Method not allowed

Hi,

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

Hey @azadharsana

Welcome to the community! :trophy:

Do you have any documentarion for the endpoints / API you’re using?

Do you know that the URL that works with a GET request, has a POST method implemented?

You mentioned that this has already been tested on a different platform, could you expand on that please?

Hi @azadharsana,

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.

Hi @azadharsana,

Try to turn off “ssl cerificate verification” on Postman setting
just go to Setting -> general -> turn off ssl cerificate verification

1 Like

Hi, I meet the same 405 error, I send a post which talk about my problem more in detail, could you please help me ?

Thank you in advance !

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}”

I had the same problem and this wound up being the fix. THANKS.

I was facing the same problem. I just turned off the Header entry Content-Type: application/xml and then it worked properly.

i was able to solve this problem by re-writing the view and URL (endpoint)