Hi,
Please find a python script to list issues and to create project to a JIRA database.
# # from jira.client import JIRA from jira.exceptions import JIRAError user = 'admin' password = 'admin' server = 'http://10.5.123.121:8080' jira = JIRA(basic_auth=(user, password), options={'server': server}) # a username/password tuple # Get the mutable application properties for this server (requires jira-system-administrators permission) props = jira.application_properties() # Find all issues reported by the admin issues = jira.search_issues('assignee=admin') print "issues " + "(" + str(len(issues)) + "):" + str(issues) projname ="ProjetCreatedFromPython" projkey ="PROJPYTHON" projassignee =user try: proj = jira.project(projkey) except JIRAError: print "Create " + projname + "(" + projkey + ")" jira.create_project(projkey, projname, projassignee)
This gives the following output
ERROR:root:Unexpected result while running create project. Server response saved in d:\donnees\u00p3038\appdata\local\temp\python-jira-error-create-project-dkgnla.html for further investigation [HTTP response=200]. issues (6):[<JIRA Issue: key=u'TST-8', id=u'10602'>, <JIRA Issue: key=u'TST-7', id=u'10601'>, <JIRA Issue: key=u'TST-6', id=u'10600'>, <JIRA Issue: key=u'TST-4', id=u'10502'>, <JIRA Issue: key=u'TST-3', id=u'10501'>, <JIRA Issue: key=u'TST-2', id=u'10500'>] Create ProjetCreatedFromPython(PROJPYTHON)
Listing issues works fine.
But creating a project fails with the error " Missing XSRF security token"
JIRA database is accessible through browser but I need to access via jira-python to automate project configuration.
Any hint?
Thanks in advance.
Thierry
Community moderators have prevented the ability to post new answers.
Hi Thierry,
You can disable XSRF token in order to avoid problems as the one you're seeing. This can be done following these steps:
I hope it helps.
Cheers
This doesn't work for ON DEMAND, see https://jira.atlassian.com/browse/JRA-39153Any other workarounds?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thks Tiago.
This helps to go further.
But next error is "Administrator access", and project cannot be created.
But using same id, it works from a browser.
Is there anything in particular to configure to be able to create project from python?
Thks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.