首先,檢查該字段正被提取:
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