我是jira python的新手。我正在尝试对jira管理进行一些自动化,长期以来一直被阻止创建问题,并使用jira python官方文档。
我对create_sissue()方法的createmeta感到困惑。经过反复尝试,我被一个奇怪的http400错误阻止,后面跟着一个带有本地地址的url。
环境:
操作系统,Windows 10。
Anaconda中的Spyder IDE(安装了Python 3.5的最新版本)
吉拉·python,1.0.7
在部署的定制JIRA上有几个“项目”,我对项目“ZXQ”感兴趣,在这个项目中,我手动创建了一个问题,需要“项目”、“问题类型”、“摘要”和“优先级”(这是我在stackoverflow上的第一篇文章,我没有权限上传图片)。
下面是代码、错误消息和创建数据。
代码:
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
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"
}
}
]
}