Skip to content Skip to sidebar Skip to footer

How Do I Use Python Requests Lib To Submit An Https Post Request

I'm trying to use the python 'requests' lib to submit an https post. however, i keep running into this error 'CSRF verification failed. Request aborted' I have reviewed all similar

Solution 1:

it missing request body csrfmiddlewaretoken, you can get it in cookies

with requests.session() as s:
    res = s.get(url)
    payload['csrfmiddlewaretoken'] = s.cookies['csrftoken']
    res = requests.post(url, data=payload, headers = header, cookies = s.cookies)
    print(res.text)

Post a Comment for "How Do I Use Python Requests Lib To Submit An Https Post Request"