3

pyral 的新手,尝试将任务添加到用户故事中。复制粘贴的已经可用,来自网络的“似乎有效”的代码。

代码:

target_story   = rally.get('UserStory', query='FormattedID = %s' % storyID, instance=True)

    info = {
             "Project"     : project,
             "WorkProduct" : target_story.ref,
             "Name"        : "USER of of ",
             "State"       : "Defined",
             "TaskIndex"   : 1,
             "Description" : "FXYZ.",
             "Estimate"    : 2.0,
             "Actuals"     :  1.0,
             "ToDo"        : 1.0,
             "Notes"       : "XYZ"
           }

    task = rally.put('Task', info)

我得到的错误:

Traceback (most recent call last):
  File "...projects/Timer/task.py", line 113, in <module>
    main()
  File "...projects/Timer/task.py", line 70, in main
    task = rally.put('Task', info)
  File "...Python27\lib\site-packages\pyral\restapi.py", line 947, in put
    response = RallyRESTResponse(self.session, context, resource, response, "shell", 0)
  File "...\Python27\lib\site-packages\pyral\rallyresp.py", line 117, in __init__
    self.content     = json.loads(response.content)
  File "...\Python27\lib\json\__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "...\Python27\lib\json\decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "...\Python27\lib\json\decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

提前致谢。注意:已检查: https ://github.com/RallyTools/RallyRestToolkitForPython/issues/21 pyral 版本:1.1.1

4

1 回答 1

0

我已经更新了上面给出的代码,现在它可以工作了:

target_story_req = rally.get('UserStory', query='FormattedID = %s' % storyID)
target_story = target_story_req.next()

project_req = rally.get('Project', fetch=True, query='Name = "%s"' % (projectID))
project = project_req.next()

info = {
         "Project"     : project.ref,
         "WorkProduct" : target_story.ref,
         "State"       : "Defined",
         "TaskIndex"   : 1,
         "Description" : "FXYZ.",
         "Estimate"    : 2,
         "Actuals"     : 1,
         "ToDo"        : 1,
         "Notes"       : "XYZ"
       }

task = rally.create('Task', info)
于 2017-04-09T07:50:25.123 回答