Python Forum

Full Version: Message not supported for all requests in python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
why I'm getting "message not supported" for all request made through python request module?

"<Response [405]>"

...
response = requests.post(url,data=json.dumps(payload), headers=myheaders,auth=(usr,pwd))
...
https://developer.mozilla.org/en-US/docs...Status/405

405 isn't "message not supported", it's "method not supported".  So whatever url your using likely doesn't accept POST.
yes its method not supported

Actually I tried with POST and GET,
For POST its message not supported and response code is 501
For GET its method not supported and response code is 405

I need to use post to configure something, but its not happening
Does it work using other means (ie: not python or requests)? Such as fiddler or in the browser?

To me, this doesn't look like an issue with requests, it looks like a missing header or something.
Yes In browser its working fine and I'm getting the response as 200.

Also when I installed ubuntu16.04 in one of my VM and in terminal I did "import request" in the python3 (which is python 3.5) terminal and also in python terminal. Import request works in python3 terminal and not in python (which is python 2.7 - default terminal).

This request.post() also the similar way its working in python3, when its fresh ubuntu.
Then I installed request module for python in ubuntu. The request.post() got message not supported on both python2 as well as python3.

I'm not sure what happens when I install python-request module.
You can get a complete list of all codes here: http://www.rfc-editor.org/pdfrfc/rfc7231.txt.pdf
or if you prefer text file, here: http://www.rfc-editor.org/rfc/rfc7231.txt
Hi Larz60+,

I get the 501 - message not supported, as per the document its a web server issue (not implemented).

If that is a web server issue "why request.post(...) working with python3 in ubuntu?"
(Jul-20-2017, 05:46 AM)Prabakaran141 Wrote: [ -> ]I get the 501 - message not supported


https://en.wikipedia.org/wiki/List_of_HTTP_status_codes Wrote:501 Not Implemented
The server either does not recognize the request method, or it lacks the ability to fulfil the request. Usually this implies future availability (e.g., a new feature of a web-service API).
It means it will not completely work for my request. In future it might be available.
(Jul-20-2017, 04:59 AM)Prabakaran141 Wrote: [ -> ]Yes In browser its working fine and I'm getting the response as 200.

That means you can do it, too, but the way you're trying to do it isn't the same as whatever the browser is doing. So open the inspector (for the good browsers, that's F12 or ctrl+j), and watch the network tab when you do it. Once you see the url, http method, and payload, try to recreate it in an external program such as fiddler. Once you have it working THERE, it should be simple for you to recreate it using requests.