1

I've been using jira-python for some time, but always for queries so far. Now I need to create a new issue from a python script - and it's not working for me.

Whatever I do, I get an E405 (method not allowed error). But it is not - repeat not - a permissions problem.

To try and track this down, I sent the POST command using curl manually. No problem, everything worked and the issue was created.

So, I assumed my code was setting up the arguments for create_issue incorrectly. I dropped into ipython, enabled pdb, and tried the create_issue() call. Sure enough, I got an Exception in the jira-python library. Moved up the stack from raise_on_error and it looked like this:

    500         url = self._get_url('issue')
    501         r = self._session.post(url, headers={'content-type': 'application/json'}, data=json.dumps(data))
--> 502         raise_on_error(r)
    503 
    504         raw_issue_json = json.loads(r.text)

Did a json.dumps(data) to recover the actual string being fed in and got:

'{"fields": {"issuetype": {"name": "Bug"}, "summary": "RFU", "project": {"key": "TW"}, "components": [{"name": "A Component"}]}}'

Which I then cut'n'paste directly as the --data parameter to curl. And it worked fine.

Which seems to imply that jira-python is not working (tried it with 0.25 and 0.18).

Nor is it a python version issue (tried it with pythons 2.7, 3.3, 3.4)

My create_issue() call looks like this:

j.create_issue(project={'key':'TW'}, issuetype={'name':'Bug'}, summary='RFU', components=[{'name':'A Component'}])

All the field values specified are valid (though different than shown here)

WTH am I doing that is so wrong? This functionality can't possibly be broken in the library

I'm working in virtualenv's and here's the output of pip freeze

argparse==1.2.1
ipython==2.1.0
jira==0.25
oauthlib==0.6.3
requests==2.3.0
requests-oauthlib==0.4.1
six==1.7.2
tlslite==0.4.6
wsgiref==0.1.2

Which was set up with a simple pip install ipython jira command

BTW, if I fetch an existing issue and then call issue.update() with suitable params, it works fine.

One other item: I'm running Ubuntu 14.04

4

1 回答 1

1

好的,我得到它的工作 - 它归结为一些内部网络变幻莫测。

我们的内部 JIRA 服务器有一个过期的证书。所以他们把它从https切换到http。

'server':'https://...'我使用并'verify':False绕过证书错误创建了我的 jira 实例。jira-python 大概只是通过 http 连接并将其用于所有查询。

但是当需要 POST 到网站时,我们遇到了 https 与 http 的问题。

切换到'server':'http://...'并删除该'verify'选项使其正常工作。

我在这里找到了提示

于 2014-06-16T16:52:46.267 回答