这是我在使用jira-python python模块自动将一些日志记录到JIRA时遇到的错误。
Traceback (most recent call last):
File "/home/csd-user/test/libs/utils/butler.py", line 217, in <module>
main()
File "/home/csd-user/test/libs/utils/butler.py", line 214, in main
b.log_bug_exec(url)
File "/home/csd-user/test/libs/utils/butler.py", line 47, in log_bug_exec
cls.process_file(stdout)
File "/home/csd-user/test/libs/utils/butler.py", line 108, in process_file
cls.submit_bug(bug)
File "/home/csd-user/test/libs/utils/butler.py", line 207, in submit_bug
iss = cls.my_server.create_issue(fields=bug.json_dict['fields'])
File "/opt/clearsky/lib/python2.7/site-packages/jira/client.py", line 706, in create_issue
r = self._session.post(url, data=json.dumps(data))
File "/opt/clearsky/lib/python2.7/site-packages/jira/resilientsession.py", line 81, in post
return self.__verb('POST', url, **kwargs)
File "/opt/clearsky/lib/python2.7/site-packages/jira/resilientsession.py", line 74, in __verb
raise_on_error(r, verb=verb, **kwargs)
File "/opt/clearsky/lib/python2.7/site-packages/jira/utils.py", line 120, in raise_on_error
r.status_code, error, r.url, request=request, response=r, **kwargs)
# This is the important part...
jira.utils.JIRAError: JiraError HTTP 400
text: data was not an object
url: https://jira.clearsky-data.net/rest/api/2/issue
我的问题是,就我所知,我传递的dict对象是完全有效的。
BUG FIELDS :: {'environment': 'node => 62-qa-driver12 (M3 - HA Only)\nversion => \nurl => https://jenkins.clearsky-data.net/job/BugLoggerTest/144/\ntimestamp => 2015-06-29_11-11-15\njob name => BugLoggerTest\nbuild number => 144\nversion number => Not present. Check git hash. Maybe add in processing of full failure list!\n', 'description': '', 'summary': 'Fill in Something', 'project': {'key': 'QABL'}, 'assignee': 'qa-auto', 'issuetype': {'name': 'Bug'}, 'priority': {'name': 'Major'}}
CLASS :: <type 'dict'>
由此格式化......
# creating JSON object (bug should not have to be changed after initialization)
self.json_dict = ( {"fields": {
"project": {'key': self.project},
"issuetype": {'name': self.issue_type},
"priority": {'name': self.priority},
"assignee": self.assignee,
"environment": self.environment,
"description": self.description,
"summary": self.summary } } )
这是调用以创建抛出错误的问题:
iss = cls.my_server.create_issue(fields=bug.json_dict['fields'])
# This calls a cURL POST or PUT command.
答案 0 :(得分:0)
您的受让人不是jira所期望的:
"assignee": self.assignee,
应该阅读
"assignee": {'name': self.assignee}
中看到了它
issue.update(summary='new summary', description='A new summary was added')
issue.update(assignee={'name': 'new_user'})