Here is my (non)working code:
- Code: Select all
import requests
from requests.auth import HTTPDigestAuth
requests.packages.urllib3.disable_warnings()
s = requests.session()
r = s.get('https://SERVER_IP', auth=HTTPDigestAuth('USERNAME', 'PASSWORD'), cookies={"new-cookie-identifier": "1234abcd"}, verify=False)
print r.content
payload = {'data': 'dhcp_leases'}
r1 = s.get('https://SERVER_IP/api/edge/data.json', params=payload, verify=False)
print r1.status_code
print r1.content
The first get works, and returns content (the idea being that this call would provide the session cookie.) The second get is where the rubber meets the road. However, the session doesn't seem to stay active and I get:
- Code: Select all
403
{"success":false,"errors":["Permission denied"]}
I've tried many things, but none successful. I'm sure that it's something pretty simple, but I haven't been able to find workable examples to draw from. Hopefully, someone can point me in the right direction.
Dave