I am trying to call an API and pass some parameters to it.
My endpoint should look like: https://example.com?q=food
(food
is the parameter)
import requests
parametervalue = "food"
r = requests.get("https://example.com/q=", parametervalue)
When I do print r.url
, I do not get the correct result - the value is not passed.
Error:
r = requests.get('https://example.com', params={'1':parametervalue})
File "/usr/lib/python2.7/dist-packages/requests/api.py", line 55, in get
return request('get', url, **kwargs)
Update:
Answer posted below. Thank you.
Note: The SSL error mentioned in the post was due to me running Python 2.7. I used python 3 and it fixed the issue.