RallyAPI:如何创建 UserStory 并将其与功能关联? [英] RallyAPI: How do I create a UserStory and relate it to a Feature?

查看:34
本文介绍了RallyAPI:如何创建 UserStory 并将其与功能关联?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我正在编写一个应用程序来充实"Rally 中的新客户.它将具有创建模板的工具,这些模板将首先添加:

So, I'm writing an app to 'flesh out' new clients in Rally. It will have tools to create templates which will add first:

  1. 添加功能"
  2. 在该功能"下添加用户故事"
  3. 在这些用户故事"下单独添加任务"

我已经想出了第 1 步.但是如何关联任何我从可怕而神秘的文档中无法弄清楚的东西.这是我到目前为止所拥有的:

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?...

推荐答案

它忽略了 WorkProduct,因为 WorkProduct 不是 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 中被指定为 refs (/type/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:如何创建 UserStory 并将其与功能关联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆