Reputation: 2620
I am trying to access an api with key provided to me. here is the code.
import requests
import json
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
urletf='https://someapi'
s = requests.Session()
s.verify = False
resp_mf = s.get(urletf, params={"key":"somekey" }, stream=True)
content = resp_mf.content
This gives me error as :Failed to establish connection
when I try the URL in the browser or Postman I get response back.
Any idea why Python is giving error? I am expecting json back (if it matters) Thanks for help.
Upvotes: 0
Views: 15505
Reputation: 2620
My company has a proxy and I had to use it to access the api.
This code works.
import requests
import json
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
proxies = {<someproxy>}
urletf='https://someapi'
s = requests.Session()
s.verify = False
resp_mf = s.get(urletf, params={"key":"somekey" },proxies=proxies, stream=True)
content = resp_mf.content
Upvotes: 2