首先,检查该字段正被提取:
query.fetch = "c_MyCustomField"
接下来,如果使用v2.0,则必须明确设置WS API的一个版本。
c_前缀特定于WS API版本v2.0。 默认情况下,rally_api将使用WS API的先前版本。 如果你没有明确在你的代码中指定WS API版本,指的是自定义字段,因为它是在WS API的先前版本refered到,没有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无线th最新的rally_api宝石。
gem list -l
应该列出rally_api 0.9.20
注意,上了年纪rally_rest_api不再支持。它也不适用于V2.0的WS API。
这里是一个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] = "[email protected]"
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 = [email protected])"
results = @rally.find(query)
results.each do |d|
puts "MyCustomField: #{d["c_MyCustomField"]}"
d.read
end