ProgSky
ProgSky

Reputation: 2620

Python requests failing with Failed to Establish new Connection Error 10061

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

enter image description here

when I try the URL in the browser or Postman I get response back.

https://someapi?key=myKey

Any idea why Python is giving error? I am expecting json back (if it matters) Thanks for help.

Upvotes: 0

Views: 15505

Answers (1)

ProgSky
ProgSky

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

Related Questions