[Django]-GET request with postman is working, but it does not work with python (HTTPSConnectionPool)

3๐Ÿ‘

โœ…

I found out that the method I was using was not valid for internal HTTPS requests. I used ifconfig to see the local ip-address, and used that instead of the host and put the ip-address in ALLOWED_HOSTS in settings.py. Furthermore, i disabled SSL verification with verify=False

def getDonations():

    url = "https://172.19.10.5/api/donations"
    payload = ""
    headers = {
    'cache-control': "no-cache",
    }

    response = requests.request("GET", url, data=payload, headers=headers, timeout=5, verify=False)
    print(response.text)
    return response.text

๐Ÿ‘คgiggitygoat

0๐Ÿ‘

Try Verifying the session

session = requests.Session()
session.verify = True

session.get("webpageUrl/api/donations", headers={'Content-Type':'application/json'}, timeout=5, verify=True)
๐Ÿ‘คTom

Leave a comment