gpt4 book ai didi

python - 使用 python 在 Rally 中创建新缺陷时出现错误

转载 作者:太空宇宙 更新时间:2023-11-03 21:23:52 25 4
gpt4 key购买 nike

以下是我使用 python 添加新缺陷以进行集会的代码:

import sys import time from pyral import Rally, rallyWorkset
server = "rally1.rallydev.com"
user = "*****"
password = "****"
apikey = "****"
workspace = "****"
project = "****"
rally = Rally(server, user=user, password=password,apikey=apikey, workspace=workspace, project=project)

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

priority = "3.Normal"
severity = "Major Problem"
name = "prabhakar.sharma@***.com"
#defectID = 'INC0547865'
description = "A Test Rally User Story created using python API now, start working on it as fast as you all could !!"
user = rally.getUserInfo(username=name).pop(0)
#rally.setProject(proj)
print("%s %s "% (project.oid , user.ref))
defect_data = { "Project" : project.ref,
"SubmittedBy" : user.ref,
"Name" : name,
"Severity" : severity,
"Priority" : priority,
"State" : "Open",
"ScheduleState" : "Defined",
"Owner": user.ref,
"Description" : description
}


defect = rally.create('Defect', defect_data) print("Defect created, ObjectID: %s FormattedID: %s" % (defect.oid, defect.FormattedID))

回溯:

Traceback (most recent call last): File "pythonrally.py", line 186, in defect = rally.create('Defect', defect_data) File "C:\Users\PRABHAKAR.SHARMA\AppData\Local\Programs\Python\Python37\pyral\restapi.py", line 1024, in put raise RallyRESTAPIError(problem) pyral.restapi.RallyRESTAPIError: 422 Validation error: Defect.PRJ# should not be null

最佳答案

变化:

  1. 必须使用“username=name”(其中“name”是登录 ID)而不是“username=user”。
  2. “何时”字段不是缺陷的一部分(在下面注释掉)。
  3. 字段“PRJ#”不是缺陷的一部分(在下面注释掉)。
  4. 项目引用必须指定为“proj.ref”而不是“project.ref”。

    $ diff code.orig code.new
    10c10
    < user = rally.getUserInfo(username=user).pop(0)
    ---
    > user = rally.getUserInfo(username=name).pop(0)
    12,14c12,14
    < defect_data = { "When" : when,
    < "PRJ#" : project.oid,
    < "Project" : project.ref,
    ---
    > defect_data = { #"When" : when,
    > #"PRJ#" : proj.oid,
    > "Project" : proj.ref,

上述更改对我有用。

关于python - 使用 python 在 Rally 中创建新缺陷时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54001424/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com