Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Funny, I was working on this yesterday for the <a href="https://studio.plugins.atlassian.com/browse/JCLIMD" rel="nofollow">JIRA Python CLI</a>. I took the approach of using the REST API to get an authentication cookie and a custom opener. The example below shows using the opener to post data to a page to add a component, but you could replace that with a call to the correct URL for a different REST call.</p> <pre><code> """ Demonstration of using Python for a RESTful call to JIRA Matt Doar CustomWare """ import urllib import urllib2 import cookielib jira_serverurl = "http://jira.example.com:8080" creds = { "username" : "admin", "password" : "admin" } authurl = jira_serverurl + "/rest/auth/latest/session" # Get the authentication cookie using the REST API cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) req = urllib2.Request(authurl) req.add_data('{ "username" : "admin", "password" : "admin" }') req.add_header("Content-type", "application/json") req.add_header("Accept", "application/json") fp = opener.open(req) fp.close() add_component_url = jira_serverurl + "/secure/project/AddComponent.jspa?pid=10020&amp;name=ABC4" print "Using %s" % (add_component_url) # Have to add data to make urllib2 send a POST values = {} data = urllib.urlencode(values) # Have to tell JIRA to not use a form token headers = {'X-Atlassian-Token': 'no-check'} request = urllib2.Request(add_component_url, data, headers=headers) fp = opener.open(request) print fp.read() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload