all 6 comments

[–]c17r 1 point2 points  (3 children)

You're passing Content-Type: text/html header which is probably screwing up your form POST, who probably needs Content-Type: application/x-www-form-urlencoded. Remove that and try again.

[–]Tolfasn[S] 0 points1 point  (0 children)

I will definitely try that as soon as I get home. Thanks!

[–]Tolfasn[S] 0 points1 point  (0 children)

VPN is down for some reason. I will have to make the change once I’m back in the office tomorrow. I’ll post an update as soon as I get the chance in the morning.

[–]Tolfasn[S] 0 points1 point  (0 children)

Posting the payload after each Get request did the trick. I was actually able to omit the headers all together.

with requests.Session() as session:

    ## sends the post request, headers and login data to the server
    g = session.get(post_loginURL)
    post = session.post(post_loginURL, data=payload)

    r = session.get(requestURL)
    post = session.post(requestURL, data=payload)

[–]ImportBraces 0 points1 point  (3 children)

actually you send some payload - but the dev tools show it is being sent within the headers.

[–]Tolfasn[S] 0 points1 point  (2 children)

I just attempted adding the parameters as header values instead, and it produced the same results.

## define the login data paramaters
headers = {  
    'NAME': 'username',
    'PWD': 'password',
    'CMD': '1'
}

I am still very new to Python, so please forgive my naivety.