RalyAPI:我如何创建一个UserStory并将其与一个功能关联起来

本文关键字:一个 功能 起来 关联 UserStory 创建 RalyAPI 何创建 | 更新日期: 2023-09-27 18:22:51

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

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

我已经想出了第一步。但是,如何将我无法从可怕而神秘的文档中找到的任何东西联系起来。到目前为止,我拥有的是:

 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);
        }

运行此操作会同时创建两者,但不会发生关联。我收到警告:

Ignored JSON element hierarchicalrequirement.WorkProduct during processing of this request.

为什么它武断地忽略了这一点?。。。

RalyAPI:我如何创建一个UserStory并将其与一个功能关联起来

它忽略了WorkProduct,因为WorkProduct不是层次结构需求中的有效字段。要指定用于设置故事的功能父级的字段称为PortfolioItem。

toCreate["PortfolioItem"] = Ref.GetRelativeRef(createFeatureResult.Reference);

此外,对象关系在WSAPI中被指定为refs(/type/id),因此您可以直接从createFeatureResult传入引用。

很抱歉您发现api令人沮丧。它肯定有一些奇怪的暗角,但一旦你稍微使用它并了解各种域对象是如何关联的,我想你会发现它非常强大和一致。