Python Forum
Message not supported for all requests in python - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Message not supported for all requests in python (/thread-4046.html)



Message not supported for all requests in python - Prabakaran141 - Jul-19-2017

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))
...



RE: Message not supported for all requests in python - nilamo - Jul-19-2017

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405

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


RE: Message not supported for all requests in python - Prabakaran141 - Jul-19-2017

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


RE: Message not supported for all requests in python - nilamo - Jul-19-2017

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.


RE: Message not supported for all requests in python - Prabakaran141 - Jul-20-2017

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.


RE: Message not supported for all requests in python - Larz60+ - Jul-20-2017

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


RE: Message not supported for all requests in python - Prabakaran141 - Jul-20-2017

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?"


RE: Message not supported for all requests in python - buran - Jul-20-2017

(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).



RE: Message not supported for all requests in python - Prabakaran141 - Jul-20-2017

It means it will not completely work for my request. In future it might be available.


RE: Message not supported for all requests in python - nilamo - Jul-20-2017

(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.