Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

JIRA REST API cookie based authentication fails when used with python requests

I've been trying to get issue data from the REST API v2 by using cookie based authentication and the python requests library, the /auth/1/session requests returns a 200, cookies are set but all following requests on the same requests.Session object return a 401:

> from requests import Session
> s = Session()
> res ="https://jira.url/jira/rest/auth/1/session",
... json={"username":"user","password":"pass"})
> res.status_code
> s.cookies
<RequestsCookieJar[<Cookie JSESSIONID=... for jira.url/jira>, <Cookie atlassian.xsrf.token=... for jira.url/jira>]>
> res = s.get("https://jira.url/jira/rest/api/2/issue/ISSUE-100")
> res.status_code
> r.request.headers
{'User-Agent': 'python-requests/2.18.4', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Cookie': 'JSESSIONID=...; atlassian.xsrf.token=...'}

(In case it's not clear: I removed cookie contents, urls and credentials in the example above)

Furthermore, I get the following message in the response:

os_authType was 'any' and an invalid cookie was sent.

 It seems a bit strange; I'm using the same session, which keeps the connection alive by default, and still, the session cookie gets invalidated. 

Is this a problem by JIRA or does requests just not actually keep the Session open?


1 answer

0 votes
Gonchik Tsymzhitov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 30, 2019


Can you try to trace the requests?


I had the same problem here


After keeping as object it works well. 

Vincent van ’t Zand
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Mar 27, 2023 • edited

Sorry, that link shows the current situation, but what was it before? You didn’t subclass object?

Suggest an answer

Log in or Sign up to answer