Hi all
i have to open this link
http://www.mytest.com/rest?api_key=username:password
i do a post or a get call
host= "http://www.mytest.com/rest"
queryParams = {"api_key" : "{}:{}".format(username, password)}
requests.post(host, params=queryString)
and the server return 500 error, this is because the requests send that call
http://www.mytest.com/rest?api_key=username%3Apassword
and is not correct
have some solution?
thanks in advance for your help
I believe the only solution at this time is to drop the params keyword argument and just use a plain old string.
requests.post('{0}?api_key={1}:{2}'.format(host, username, password))
Your query parameter api_key will be URL encoded as api_key?username%3Apassword by requests. This is correct, passing it unencoded using a plain colon : is not recommended.
So if the server you try to access can't URL decode the parameter value, the server should be fixed.
Requests will avoid aggressively handling your string if you do what @patallen suggests, which should resolve your problem, but @lutzhorn is right: the server should accept both, and is at fault here. :smile:
I'd also add that sending a password via a http connection isn't a good
idea either, especially as part of the url
Hi All
thank you for your help
@lutzhorn is true, and i have reported the problem as well, but i'm sure that is a bit difficult to solve from the server part, is Asterisk the open source PBX and have a very large list of issues.
@TetraEtc yes but the URL is into the internal network and have no external access
@Lukasa and @patallen , thank you i will use your suggestion, hope is work well