headers = {"accept": "application/json",
"key": "someSecretKey",
'User-Agent': None,
'Connection': None,
'Accept-Encoding': None}
url=r'https://something.something'
idVar='id_123'
r = requests.get(url, headers=headers, params={'id': idVar})
if I send this straight up, the url I get upon debugging is:
https://something.something?id=%22id_123%22
which causes a 404 error with the API. I confirmed this by using curlify to generate a curl string to use in terminal.
The issue is fixed when I do a .replace('%22','') on the curlify string to get the following url which does work when using curl!!
https://something.something?id=id_123
I guess the API service must be resilient to this. But in the meantime, how do tell requests library to not add the quote markers in the url string?
question from:
https://stackoverflow.com/questions/65931886/python-requests-adding-quotes-around-parameters-causing-get-failure 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…