Skip to content

Instantly share code, notes, and snippets.

@azakordonets
Created September 22, 2014 10:05
Show Gist options
  • Save azakordonets/c1c9608e5af8271899f5 to your computer and use it in GitHub Desktop.
Save azakordonets/c1c9608e5af8271899f5 to your computer and use it in GitHub Desktop.
This scrip allows you easily to get full list of all your JIRA instance fields
import urllib
import urllib2
import cookielib
import json
jira_serverurl = "{url to your jira environment}"
creds = { "username" : "admin", "password" : "test" }
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" : "test" }')
req.add_header("Content-type", "application/json")
req.add_header("Accept", "application/json")
fp = opener.open(req)
fp.close()
add_component_url = jira_serverurl + "/rest/api/2/field"
request = urllib2.Request(add_component_url)
fp = opener.open(request)
json = json.loads(fp.read())
for field in json:
print field['name'].encode('utf8')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment