I'm new to jira-python. I am trying to automate a bit on jira management, blocked on creating issue for a long time, going along with the jira-python official documents. I'm confused with the createmeta of create_issue() method. After trial and error, I'm blocked with a strange http 400 error followed by a url with a local address.
OS, Windows 10.
Spyder IDE in Anaconda(latest version with Python 3.5 installed)
jira-python, 1.0.7
There are several 'projects' on the customized JIRA deployed, and I'm interested on the project-'ZXQ', in which I create an issue manually with 'Project', 'Issue Type', 'Summary', and 'Priority' required (This is my first post on stackoverflow, and I don't have permission to upload pic.).
Here are the code, error message, and createmeta in tidy manner.
from jira import JIRA
authedjira = JIRA(server = 'http://xxx.xx.xx.xxx:48082',
basic_auth = ('username', 'password'))
issue_dict = {
'project': {'key': 'ZXQ'},
'summary': 'New issue from jira-python',
'description': 'Look into this one',
'issuetype': {'name': 'Bug'}
# 'priority' : '0-Blocked'
}
new_issue = authedjira.create_issue(fields=issue_dict)
runfile('.../Spyder/test/tcreateissue.py', wdir='.../Spyder/test')
Traceback (most recent call last):
File "<ipython-input-15-16266e46b0c1>", line 1, in <module>
runfile('.../Spyder/test/tcreateissue.py', wdir='.../Spyder/test')
File "C:\App\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 714, in runfile
execfile(filename, namespace)
File "C:\App\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 89, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File ".../Spyder/test/tcreateissue.py", line 21, in <module>
new_issue = authedjira.create_issue(fields=issue_dict)
File "C:\App\Anaconda3\lib\site-packages\jira\client.py", line 897, in create_issue
r = self._session.post(url, data=json.dumps(data))
File "C:\App\Anaconda3\lib\site-packages\jira\resilientsession.py", line 152, in post
return self.__verb('POST', url, **kwargs)
File "C:\App\Anaconda3\lib\site-packages\jira\resilientsession.py", line 145, in __verb
raise_on_error(response, verb=verb, **kwargs)
File "C:\App\Anaconda3\lib\site-packages\jira\resilientsession.py", line 55, in raise_on_error
r.status_code, error, r.url, request=request, response=r, **kwargs)
JIRAError: JiraError HTTP 400 url: http://xxx.xx.xx.xxx:48082/rest/api/2/issue details: C:\Users\ABSmi\AppData\Local\Temp\jiraerror-jjcv0rwp.tmp
Content in jiraerror-jjcv0rwp.tmp:
response headers = {'Vary': 'User-Agent', 'Content-Encoding': 'gzip', 'X-Seraph-LoginReason': 'OK', 'X-AREQUESTID': '1024x353617x1', 'Transfer-Encoding': 'chunked', 'Date': 'Sun, 31 Jul 2016 09:04:51 GMT', 'Server': 'Apache-Coyote/1.1', 'X-ASESSIONID': 'sen5dn', 'X-Content-Type-Options': 'nosniff', 'Connection': 'close', 'X-AUSERNAME': 'zhaoya', 'X-ASEN': 'SEN-5285313', 'Content-Type': 'application/json;charset=UTF-8', 'Cache-Control': 'no-cache, no-store, no-transform'}
response text = {"errorMessages":[],"errors":{"description":"Field 'description' cannot be set. It is not on the appropriate screen, or unknown."}}
{
"expand": "projects",
================================================================================================================================================
================================================================================================================================================
================================================================================================================================================
"projects": [
================================================================================================
================================================================================================
================================================================================================
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/project/11001",
"id": "11001",
"name": "Precheck",
"key": "PRECHECK",
"issuetypes": [
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/1",
"id": "1",
"name": "Bug",
"description": "A problem which impairs or prevents the functions of the product.",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/bug.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/2",
"id": "2",
"name": "New Feature",
"description": "A new feature of the product, which has yet to be developed.",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/newfeature.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/3",
"id": "3",
"name": "Task",
"description": "A task that needs to be done.",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/task.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/4",
"id": "4",
"name": "Improvement",
"description": "An improvement or enhancement to an existing feature or task.",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/improvement.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/5",
"id": "5",
"name": "Sub-task",
"description": "The sub-task of the issue",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/subtask_alternate.png",
"subtask": true
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/10001",
"id": "10001",
"name": "\u6d4b\u8bd5",
"description": "\u6b64\u53d1\u5e03\u7c7b\u578b\u7528\u4e8e\u5728 Jira \u4e2d\u521b\u5efa Zephyr \u6d4b\u8bd5\u3002",
"iconUrl": "http://xxx.xx.xx.xxx:48082/download/resources/com.thed.zephyr.je/images/icons/ico_zephyr_issuetype.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/10100",
"id": "10100",
"name": "Epic",
"description": "Created by JIRA Agile - do not edit or delete. Issue type for a big user story that needs to be broken down.",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/epic.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/10200",
"id": "10200",
"name": "Ticket Template(WBSGantt)",
"description": "Ticket Template",
"iconUrl": "http://xxx.xx.xx.xxx:48082/download/resources/jp.ricksoft.plugins.wbsgantt-for-jira:wbsgantt-resources/images/template-icon.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/10201",
"id": "10201",
"name": "Phase",
"description": "Project Development Phase",
"iconUrl": "http://xxx.xx.xx.xxx:48082/download/resources/jp.ricksoft.plugins.wbsgantt-for-jira:wbsgantt-resources/images/phase-icon.png",
"subtask": false
}
],
"avatarUrls": {
"24x24": "http://xxx.xx.xx.xxx:48082/secure/projectavatar?size=small&pid=11001&avatarId=10011",
"16x16": "http://xxx.xx.xx.xxx:48082/secure/projectavatar?size=xsmall&pid=11001&avatarId=10011",
"32x32": "http://xxx.xx.xx.xxx:48082/secure/projectavatar?size=medium&pid=11001&avatarId=10011",
"48x48": "http://xxx.xx.xx.xxx:48082/secure/projectavatar?pid=11001&avatarId=10011"
}
},
================================================================================================
================================================================================================
================================================================================================
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/project/11200",
"id": "11200",
"name": "\u4e8b\u4ef6\u7ba1\u7406",
"key": "SJGL",
"issuetypes": [
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/5",
"id": "5",
"name": "Sub-task",
"description": "The sub-task of the issue",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/subtask_alternate.png",
"subtask": true
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/2",
"id": "2",
"name": "New Feature",
"description": "A new feature of the product, which has yet to be developed.",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/newfeature.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/3",
"id": "3",
"name": "Task",
"description": "A task that needs to be done.",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/task.png",
"subtask": false
}
],
"avatarUrls": {
"24x24": "http://xxx.xx.xx.xxx:48082/secure/projectavatar?size=small&pid=11200&avatarId=10011",
"16x16": "http://xxx.xx.xx.xxx:48082/secure/projectavatar?size=xsmall&pid=11200&avatarId=10011",
"32x32": "http://xxx.xx.xx.xxx:48082/secure/projectavatar?size=medium&pid=11200&avatarId=10011",
"48x48": "http://xxx.xx.xx.xxx:48082/secure/projectavatar?pid=11200&avatarId=10011"
}
},
================================================================================================
================================================================================================
================================================================================================
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/project/10201",
"id": "10201",
"name": "\u4ea7\u54c1\u5185\u90e8\u4ea4\u6d41",
"key": "CP",
"issuetypes": [
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/1",
"id": "1",
"name": "Bug",
"description": "A problem which impairs or prevents the functions of the product.",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/bug.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/2",
"id": "2",
"name": "New Feature",
"description": "A new feature of the product, which has yet to be developed.",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/newfeature.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/3",
"id": "3",
"name": "Task",
"description": "A task that needs to be done.",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/task.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/4",
"id": "4",
"name": "Improvement",
"description": "An improvement or enhancement to an existing feature or task.",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/improvement.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/5",
"id": "5",
"name": "Sub-task",
"description": "The sub-task of the issue",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/subtask_alternate.png",
"subtask": true
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/10001",
"id": "10001",
"name": "\u6d4b\u8bd5",
"description": "\u6b64\u53d1\u5e03\u7c7b\u578b\u7528\u4e8e\u5728 Jira \u4e2d\u521b\u5efa Zephyr \u6d4b\u8bd5\u3002",
"iconUrl": "http://xxx.xx.xx.xxx:48082/download/resources/com.thed.zephyr.je/images/icons/ico_zephyr_issuetype.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/10100",
"id": "10100",
"name": "Epic",
"description": "Created by JIRA Agile - do not edit or delete. Issue type for a big user story that needs to be broken down.",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/epic.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/10200",
"id": "10200",
"name": "Ticket Template(WBSGantt)",
"description": "Ticket Template",
"iconUrl": "http://xxx.xx.xx.xxx:48082/download/resources/jp.ricksoft.plugins.wbsgantt-for-jira:wbsgantt-resources/images/template-icon.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/10201",
"id": "10201",
"name": "Phase",
"description": "Project Development Phase",
"iconUrl": "http://xxx.xx.xx.xxx:48082/download/resources/jp.ricksoft.plugins.wbsgantt-for-jira:wbsgantt-resources/images/phase-icon.png",
"subtask": false
}
],
"avatarUrls": {
"24x24": "http://xxx.xx.xx.xxx:48082/secure/projectavatar?size=small&pid=10201&avatarId=10011",
"16x16": "http://xxx.xx.xx.xxx:48082/secure/projectavatar?size=xsmall&pid=10201&avatarId=10011",
"32x32": "http://xxx.xx.xx.xxx:48082/secure/projectavatar?size=medium&pid=10201&avatarId=10011",
"48x48": "http://xxx.xx.xx.xxx:48082/secure/projectavatar?pid=10201&avatarId=10011"
}
},
================================================================================================
================================================================================================
================================================================================================
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/project/11009",
"id": "11009",
"name": "\u4ea7\u54c1\u8bbe\u8ba1\u9700\u6c42",
"key": "PD",
"issuetypes": [
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/1",
"id": "1",
"name": "Bug",
"description": "A problem which impairs or prevents the functions of the product.",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/bug.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/2",
"id": "2",
"name": "New Feature",
"description": "A new feature of the product, which has yet to be developed.",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/newfeature.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/3",
"id": "3",
"name": "Task",
"description": "A task that needs to be done.",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/task.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/4",
"id": "4",
"name": "Improvement",
"description": "An improvement or enhancement to an existing feature or task.",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/improvement.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/5",
"id": "5",
"name": "Sub-task",
"description": "The sub-task of the issue",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/subtask_alternate.png",
"subtask": true
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/10001",
"id": "10001",
"name": "\u6d4b\u8bd5",
"description": "\u6b64\u53d1\u5e03\u7c7b\u578b\u7528\u4e8e\u5728 Jira \u4e2d\u521b\u5efa Zephyr \u6d4b\u8bd5\u3002",
"iconUrl": "http://xxx.xx.xx.xxx:48082/download/resources/com.thed.zephyr.je/images/icons/ico_zephyr_issuetype.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/10100",
"id": "10100",
"name": "Epic",
"description": "Created by JIRA Agile - do not edit or delete. Issue type for a big user story that needs to be broken down.",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/epic.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/10200",
"id": "10200",
"name": "Ticket Template(WBSGantt)",
"description": "Ticket Template",
"iconUrl": "http://xxx.xx.xx.xxx:48082/download/resources/jp.ricksoft.plugins.wbsgantt-for-jira:wbsgantt-resources/images/template-icon.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/10201",
"id": "10201",
"name": "Phase",
"description": "Project Development Phase",
"iconUrl": "http://xxx.xx.xx.xxx:48082/download/resources/jp.ricksoft.plugins.wbsgantt-for-jira:wbsgantt-resources/images/phase-icon.png",
"subtask": false
}
],
"avatarUrls": {
"24x24": "http://xxx.xx.xx.xxx:48082/secure/projectavatar?size=small&pid=11009&avatarId=10011",
"16x16": "http://xxx.xx.xx.xxx:48082/secure/projectavatar?size=xsmall&pid=11009&avatarId=10011",
"32x32": "http://xxx.xx.xx.xxx:48082/secure/projectavatar?size=medium&pid=11009&avatarId=10011",
"48x48": "http://xxx.xx.xx.xxx:48082/secure/projectavatar?pid=11009&avatarId=10011"
}
},
================================================================================================
================================================================================================
================================================================================================
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/project/10005",
"id": "10005",
"name": "\u7f3a\u9677\u7ba1\u7406\u5e73\u53f0",
"key": "ZXQ",
"issuetypes": [
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/1",
"id": "1",
"name": "Bug",
"description": "A problem which impairs or prevents the functions of the product.",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/bug.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/2",
"id": "2",
"name": "New Feature",
"description": "A new feature of the product, which has yet to be developed.",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/newfeature.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/3",
"id": "3",
"name": "Task",
"description": "A task that needs to be done.",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/task.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/4",
"id": "4",
"name": "Improvement",
"description": "An improvement or enhancement to an existing feature or task.",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/improvement.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/5",
"id": "5",
"name": "Sub-task",
"description": "The sub-task of the issue",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/subtask_alternate.png",
"subtask": true
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/10001",
"id": "10001",
"name": "\u6d4b\u8bd5",
"description": "\u6b64\u53d1\u5e03\u7c7b\u578b\u7528\u4e8e\u5728 Jira \u4e2d\u521b\u5efa Zephyr \u6d4b\u8bd5\u3002",
"iconUrl": "http://xxx.xx.xx.xxx:48082/download/resources/com.thed.zephyr.je/images/icons/ico_zephyr_issuetype.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/10100",
"id": "10100",
"name": "Epic",
"description": "Created by JIRA Agile - do not edit or delete. Issue type for a big user story that needs to be broken down.",
"iconUrl": "http://xxx.xx.xx.xxx:48082/images/icons/issuetypes/epic.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/10200",
"id": "10200",
"name": "Ticket Template(WBSGantt)",
"description": "Ticket Template",
"iconUrl": "http://xxx.xx.xx.xxx:48082/download/resources/jp.ricksoft.plugins.wbsgantt-for-jira:wbsgantt-resources/images/template-icon.png",
"subtask": false
},
{
"self": "http://xxx.xx.xx.xxx:48082/rest/api/2/issuetype/10201",
"id": "10201",
"name": "Phase",
"description": "Project Development Phase",
"iconUrl": "http://xxx.xx.xx.xxx:48082/download/resources/jp.ricksoft.plugins.wbsgantt-for-jira:wbsgantt-resources/images/phase-icon.png",
"subtask": false
}
],
"avatarUrls": {
"24x24": "http://xxx.xx.xx.xxx:48082/secure/projectavatar?size=small&pid=10005&avatarId=10011",
"16x16": "http://xxx.xx.xx.xxx:48082/secure/projectavatar?size=xsmall&pid=10005&avatarId=10011",
"32x32": "http://xxx.xx.xx.xxx:48082/secure/projectavatar?size=medium&pid=10005&avatarId=10011",
"48x48": "http://xxx.xx.xx.xxx:48082/secure/projectavatar?pid=10005&avatarId=10011"
}
}
]
}
The error detail message is:
Field 'description' cannot be set. It is not on the appropriate screen, or unknown.
If you go to the Project Settings of your project in JIRA and click on Screens then you can check the Screen Scheme that is associated with your project. The screen scheme lists which screen is used for each issue operation (create, edit, view). Your Create Screen does not contain the description field, but you do try to set it in the body of your create request. That's why you get the 400 error.
You have a few options:
More information about how project screens, schemes etc. relate to each other is available here. More information about how to configure screens is available here.