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

Problems faced with REST API using python requests

As I have seen on multiple websites and documentation, each one describes a little different method to use the JIRA API. Some use the JIRA module, some use directly request modules.

First I have explained the way I was able to create issues using session:

(1) By following the documentation, I was able to use CURL command to create a session, then storing JSESSIONID and atlassian.xsrf.token to a text file.(using curl -c cookie.txt -X POST -d {credentianls_json} -h {headers}

          *notice the endpoint is without the keyword /rest/ as opposed to the documentation.

           *when /rest/auth/1/session was used no JSESSIONID was generated, only xsrf token


(2) Then I was able to use this cookie.txt to create a issue. (using curl -b cookie.txt -X  POST -d {data_fields} -h {headers} )

data_fields = {with all fields and projectkey in json format}


Now when I try to do the same thing with python requests.

------------trying to do the exact same steps------------------

class JiraEverything(object):
    def __init__(self, **kwargs):
           raise JiraException('In order to use this class atleast provide 2 input')
          if 'username' in kwargs.keys():
             if 'password' in kwargs.keys():
              self.__username = kwargs['username']
              self.__password = kwargs['password']
              raise JiraException('No password found')
           raise JiraException('No username found')


  def getcookie(self):

      headers = {
        'Content-Type' : "application/json"
      params = {
        'username': self.__username,
        'password': self.__password
       r ='',headers =                headers, params = params)

         raise JiraException('Could not connect to API, verify your username and password')

#####able to get CookieJar with JSESSIONID and xsrf

###trying to use this to generate new issue

    new_headers = {
         'Content-Type' : "application/json",
         'Set-Cookie' : r.headers['Set-Cookie']

      data = {with all fields and projectkey in json format}

      rr ='', headers =       new_headers, data = data)

      ###########I get 400 error

I have tried with multiple endpoint like createmeta but this url works with curl command. I am not able to find any solution to this problem. If anyone has any idea what is going on. Please provide your input. Thanks







Log in or Sign up to comment