title: HP ALM Python rest api - How to properly pass cookie for API calls
body: <p>How to pass the HP ALM authentication session object for rest api calls. I am following some examples to connect to HP ALM via REST API to run basic CRUD operations. </p>
  
  <p>One of the example - <a href="https://github.com/vkosuri/py-hpalm/blob/master/hpalm/hpalm.py" rel="nofollow noreferrer">https://github.com/vkosuri/py-hpalm/blob/master/hpalm/hpalm.py</a> </p>
  
  <p>Below is the code snippet to establish the connection which is working perfectly fine. I am getting 200 OK response for login.</p>
  
  <pre><code>headers = {'Cookie' : lwssocookie}
  headers["Accept"] = 'application/xml'
  login_url = self.base_url + '/qcbin/authentication-point/authenticate'
  
  resp = requests.get(login_url, headers=headers, auth=HTTPBasicAuth(self.username, self.password), verify=self.verify)
  alm_session = resp.headers['Set-Cookie']
  logger.debug("Is QC session launched: %s" %alm_session)
  cookie = ";".join((lwssocookie, alm_session))
  </code></pre>
  
  <p>But all the subsequent operations are failing with unauthorized error even though I added the cookies to header</p>
  
  <pre><code>self.headers['cookie'] = cookie
  url = self.base_url + '/qcbin/rest/domains/' + self.domain + '/projects/' + self.project + '/test-instances'
  response = requests.get(url, params=params, headers=self.getheaders())
  </code></pre>
  
  <p>Can anyone please suggest how to hold the session to run operations and what am I missing here.</p>
  
  <p>I also tried to pass cookies in get call as below and even that didn't work.</p>
  
  <pre><code>response = requests.get(url, params=params, headers=self.getheaders(), cookies=cookie)
  </code></pre>
  
  <p>Thank you in advance</p>