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

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you