0

Rally 工件上有一个自定义字段,在 WS API 文档中显示为 c_MyCustomField

但它不打印:

results = @rally.find(query)

results.each do |d|
       puts "Name: #{d["Name"]}, FormattedID: #{d["FormattedID"]}, Owner: #{d["Owner"]["UserName"]}, MyCustomField: #{d["c_MyCustomField"]}"
       d.read
end
4

1 回答 1

0

首先,检查是否正在获取该字段:

query.fetch = "c_MyCustomField"

接下来,如果使用 v2.0,则必须明确设置 WS API 的版本。

c_ 前缀特定于 WS API 版本 v2.0。默认情况下, rally_api 将使用先前版本的 WS API。如果您没有在代码中明确指定 WS API 版本,请参考以前版本的 WS API 中引用的自定义字段,不带 c_:

results.each do |d|
    puts "MyCustomField: #{d["MyCustomField"]}"
    d.read
end

如果代码中设置了最新版本的WS API:

config[:version] = "v2.0"

那么自定义字段前面应该有 c_ :

results.each do |d|
    puts "MyCustomField: #{d["c_MyCustomField"]}"
    d.read
end

这假设您正在使用RallyRestTookitForRuby和最新的 rally_api gem。

gem list -l

应该列出 rally_api 0.9.20

请注意,不再支持旧的 rally_rest_api。它也不适用于 WS API v2.0。

这是一个 ruby​​ 脚本示例:

require 'rally_api'

#Setup custom app information
headers = RallyAPI::CustomHttpHeader.new()
headers.name = "My Utility"
headers.vendor = "Nick M RallyLab"
headers.version = "1.0"

# Connection to Rally
config = {:base_url => "https://rally1.rallydev.com/slm"}
config[:username] = "user@co.com"
config[:password] = "secret"
config[:workspace] = "W1"
config[:project] = "P1"
config[:version] = "v2.0"
config[:headers] = headers #from RallyAPI::CustomHttpHeader.new()

@rally = RallyAPI::RallyRestJson.new(config)

query = RallyAPI::RallyQuery.new()
query.type = :defect
query.fetch = "c_MyCustomField"
query.workspace = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/workspace/1111.js" } #optional
query.project = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/project/2222.js" } #Team Group 1 from Product 2
query.page_size = 200 #optional - default is 200
query.limit = 1000 #optional - default is 99999
query.project_scope_up = false
query.project_scope_down = true
query.order = "Name Asc"
query.query_string = "(Owner.UserName = someuser@co.com)"

results = @rally.find(query)

results.each do |d|
    puts "MyCustomField: #{d["c_MyCustomField"]}"
    d.read
end
于 2013-08-27T23:50:05.547 回答