作为孩子添加功能到主动(php api)

时间:2013-08-05 19:28:46

标签: php rally

如何将作为孩子的功能添加到预先存在的计划中?我认为它与更新功能中的状态的方式相同:

Connection::rally()->update('feature', feature_objectId, array('state' => $stateId)); 这就是我将代码添加(更新子字段)子项(功能)的方法:

Connection::rally()->update('initiative', '13298601606', array('children' => '13298601665')); 第一个对象Id用于我想要添加功能的计划,第二个ID是作为子项添加到计划中的功能。

为什么这不起作用?有人知道如何绕过这个吗?

1 个答案:

答案 0 :(得分:1)

WS API中的Initiative对象的子集合是只读的。

这是一个Ruby代码,它通过更新新功能的Parent字段来创建新功能并将其添加到现有计划中:

require 'rally_api'


#Setup custom app information
headers = RallyAPI::CustomHttpHeader.new()
headers.name = "My Utility: add feature to initiative"
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[:headers] = headers #from RallyAPI::CustomHttpHeader.new()

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

obj = {}
obj["Name"] = "new feature abc456"
new_f = @rally.create("portfolioitem/feature", obj)

query = RallyAPI::RallyQuery.new()
query.type = "portfolioitem/initiative"
query.fetch = "Name,FormattedID"
query.workspace = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/workspace/1111" } 
query.project = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/project/2222" }
query.query_string = "(FormattedID = \"I1\")"

result = @rally.find(query)
initiative = result.first

field_updates={"Parent" => initiative}
new_f.update(field_updates)