多亏了
requests.Session()
,不需要为cookie操作HTTP头。
这是我为旧的ALM版本12.01运行的代码片段,由于
this post
:
session = requests.Session()
session.verify = False
auth = session.post(hpqc_server + "authentication-point/authenticate?login-form-required=y",
auth=HTTPBasicAuth(username, password))
print("Authentication ", auth, auth.text, session.cookies)
site_session = session.post(hpqc_server + "rest/site-session")
print("Session ", site_session, site_session.text, session.cookies)
check = session.get(hpqc_server + "rest/is-authenticated")
print("Check ", check, check.text)
# Enforce JSON output
session.headers.update({ 'Accept': 'application/json' })
projects = session.get(hpqc_server + "rest/domains/DOMAIN/projects")