jira-python create_issue jiraerror http 400 本地地址为 url

jira-python create_issue jiraerror http 400 with a url of local address

我是 jira-python 的新手。我正在尝试在 jira 管理上实现一些自动化,但由于 jira-python 官方文档而被阻止了很长时间。 我对 create_issue() 方法的 createmeta 感到困惑。经过反复试验,我被一个奇怪的 http 400 错误阻止了,然后是一个 url 和一个本地地址。

环境:

OS, Windows 10.

Spyder IDE in Anaconda(latest version with Python 3.5 installed)

jira-python, 1.0.7

有几个'projects'部署在自定义的JIRA上,我对项目-'ZXQ'感兴趣,我在其中手动创建了一个问题'Project',[=需要 45=]、'Summary' 和 'Priority'(这是我在 Whosebug 上的第一个 post,我没有上传图片的权限。)。

这里是代码,错误消息,以及整洁的 createmeta。

代码:

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."}}

createmeta:

{
   "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"
         }
      }
   ]
}

错误详细消息是:

Field 'description' cannot be set. It is not on the appropriate screen, or unknown.

如果您转到 JIRA 项目的 Project Settings 并单击 Screens 然后您可以检查 Screen Scheme 与您的项目相关联。屏幕方案列出了用于每个问题操作(创建、编辑、查看)的屏幕。您的 Create Screen 不包含 description 字段,但您尝试在创建请求的正文中设置它。这就是您收到 400 错误的原因。

您有几个选择:

  • 不要在请求正文中指定描述字段
  • 更新您的创建屏幕以显示描述字段

我们提供了有关项目屏幕、方案等如何相互关联的更多信息here。 有关如何配置屏幕的更多信息,请参阅 here