'Emulating Postman Get Request with Python Request - Caused by ProxyError('Your proxy appears to only use HTTP and not HTTPS...)

Background

In postman, I have a GET request that works but uses an http proxy. I've tried to convert the "curl" command I can get from Postman into a python request. Yet I'm getting a ProxyError: (Caused by ProxyError('Your proxy appears to only use HTTP and not HTTPS, try changing your proxy URL to be HTTP. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#https-proxy-error-http-proxy', SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056)'))))'

The statement to use http doesn't really make sense, given Postman's proxy is only working on https (see settings belwo), nor does it work when I change my proxy dictionary in my python script (see below) to http.

Postman Curl Command

curl -X 'GET' \
  'https://jobs.production.tcc.services/v1/jobs/' \
  --verbose \
  --header 'accept: application/json' \
  --header "Authorization: Bearer $AUTHORIZATION"
  --data-urlencode "jobTypeID=248683a1-6d05-4774-9f5e-4e6679b99138"
  --data-urlencode "updatedSince=2022-03-19T00:00:00.000000Z"
  --data-urlencode "tenantId=922a0a8d-5814-46e8-9191-73089cd0f4cc"

Postman Proxy Settings

enter image description here

Python Request Version


url = 'https://jobs.production.tcc.services/v1/jobs/'
proxies = {"https": "https://localhost:3128"}
    
headers = {"accept": "application/json",
           "Authorization": f"Bearer {AUTHORIZATION}"}

time = "2022-03-19T00:00:00.000000Z"
params={"updatedSince": time,
        "jobTypeId": "248683a1-6d05-4774-9f5e-4e6679b99138",
        "tenantId": "922a0a8d-5814-46e8-9191-73089cd0f4cc"}  

requests.get(url, headers=headers, params=params, proxies=proxies)

Resources

https://docs.python-requests.org/en/latest/api/#module-requests



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source