The application I want to query requires Json format. Supported method is POST. I seemingly cannot find a good example of how to get a cookie from 1 query and pass it to another query (or make subsequent queries use it as part of a base package
. Could you advise what I'm doing wrong?
import json
import requests
headers = {'Content-type': 'application/json'}
data = {"username":"user1", "password":"pass1"}
login_info = json.dumps(data)
session = requests.Session()
login_url = 'https://ip/login'
response = session.post(login_url, data=login_info, headers=headers, verify=False)
print session.cookies.get_dict()
#returns the following format- {'JSESSIONID': 'DE1EE0006D53EABFA4EE0C6A50D1386A'}
query_url = 'https://ip/query'
response = session.post(query_url, cookies=session.cookies.get_dict(), headers=headers, verify=False)
print response.text
#retuns +++++++++++++++ JSESSIONID is empty! +++++++++++++