RallyAPI:如何创建一个用户故事,它涉及到一个功能? [英] RallyAPI: How do I create a UserStory and relate it to a Feature?
问题描述
所以,我正在写一个应用程序来充实在拉力赛的新客户。这将有工具来创建模板,将先加:
So, I'm writing an app to 'flesh out' new clients in Rally. It will have tools to create templates which will add first:
- 添加一个'功能'
- 下添加了'功能''UserStories
- 添加这些'UserStories'单独 在任务
我已经想通了,一步一但如何关联的事情我不能从可怕和神秘的文档弄清楚。这是我到目前为止有:
I have figured out step 1. But how to associate anything I can't figure out from the horrible and cryptic documentation. Here's what I have so far:
var FeatureToAdd = _featureRepository.GetFeatures().FirstOrDefault(x => x.Id == 2);
// Initialize the REST API. You can specify a web service version if needed in the constructor.
RallyRestApi restApi = GetRallyRestApi();
//Create an item
DynamicJsonObject toCreate = new DynamicJsonObject();
toCreate["Name"] = FeatureToAdd.Name;
toCreate["Description"] = FeatureToAdd.Description;
// important to which this belongs, but I no ID I ever use works
//toCreate["Workspace"] = "/workspace/" + WebConfigurationManager.AppSettings["RallyAPIWorkspaceID"];
//toCreate["Project"] = "/project/XXXXX";
//toCreate["Iteration"] = "/iteration/XXXXXX";
// create feature - feature is under PortfolioItem
CreateResult createFeatureResult = restApi.Create("PortfolioItem/Feature", toCreate);
// scrape ID off the end of the reference
var pureId = createFeatureResult.Reference.Substring(createFeatureResult.Reference.LastIndexOf('/') + 1);
// add UserStories
foreach (UserStory u in FeatureToAdd.UserStories)
{
toCreate = new DynamicJsonObject();
toCreate["Name"] =u.Name;
toCreate["Description"] = u.Description;
toCreate["WorkProduct"] = "PortfolioItem/Feature/" + pureId;
//toCreate["WorkProduct"] = createFeatureResult.Reference;<- tried this too
// hierarchicalrequirement = UserStory
CreateResult createUserStoryResult = restApi.Create("hierarchicalrequirement", toCreate);
}
运行这个既创造,但没有任何关联发生。我得到一个警告:
Running this creates both, but no association happens. I get a warning:
Ignored JSON element hierarchicalrequirement.WorkProduct during processing of this request.
为什么会随意坐视不理?...
Why did it arbitrarily ignore this?...
推荐答案
这忽略了工作产品,因为工作产品不在HierarchicalRequirement有效的字段。要指定设置一个故事的特点父的字段称为PortfolioItem。
It ignored WorkProduct because WorkProduct is not a valid field on HierarchicalRequirement. The field you want to specify to set the feature parent of a story is called PortfolioItem.
toCreate["PortfolioItem"] = Ref.GetRelativeRef(createFeatureResult.Reference);
另外,对象关系被指定为在WSAPI作为裁判(/类型/ ID),所以你只要直接从createFeatureResult参考传递。
Also, object relationships are specified as in WSAPI as refs (/type/id) so you can just directly pass in the reference from the createFeatureResult.
对不起你发现这个API是令人沮丧的。它肯定有一些奇怪的黑暗角落,但一旦你使用了一下,得到了不同的域对象是如何关联的感觉我想你会发现它是非常强大和一致的。
Sorry you're finding the api to be frustrating. It definitely has some weird dark corners but once you use it a bit and get a feel for how the various domain objects are related I think you'll find it to be quite powerful and consistent.
这篇关于RallyAPI:如何创建一个用户故事,它涉及到一个功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!