RallAPI:如何创建UserStory并将其与EpicStory相关联

本文关键字:EpicStory 关联 UserStory 何创建 创建 RallAPI | 更新日期: 2023-09-27 18:26:12

我之前问过如何在RallyApi中创建"UserStory"并将其与"Feature"关联。

现在,我正在询问如何创建EpicStory。然后,创建一个UserStory并将其与EpicStory关联。

下面,我在出现错误的地方做了标记。我不知道该设置什么参数。错误为:"无法设置Portfolio Item的值:无法在属性Portfolio Items中使用类型UserStory"

到目前为止,我拥有的是:

 // Initialize the REST API. You can specify a web service version if needed in the constructor.
        RallyRestApi restApi = GetRallyRestApi();
        // Create their Json object for this Feature
        DynamicJsonObject toCreate = new DynamicJsonObject();
        toCreate["Name"] = FeatureToAdd.Name;
        toCreate["Description"] = FeatureToAdd.Description;
        // create feature - (feature is under PortfolioItem)
        CreateResult createFeatureResult = restApi.Create("PortfolioItem/Feature", toCreate);
        // add Epic Stories
        foreach (EpicStory e in FeatureToAdd.EpicStories)
        {
            toCreate = new DynamicJsonObject();
            toCreate["Name"] = e.Name;
            toCreate["Description"] = e.Description;
            toCreate["PortfolioItem"] = Ref.GetRelativeRef(createFeatureResult.Reference);
            // hierarchicalrequirement = UserStory
            CreateResult createEpicStoryResult = restApi.Create("hierarchicalrequirement", toCreate);
            // foreach userstory create the USerStory and each subsequent Task
            foreach (UserStory u in e.UserStories)
            {
                toCreate = new DynamicJsonObject();
                toCreate["Name"] = u.Name;
                toCreate["Description"] = u.Description;
                toCreate["PortfolioItem"] = Ref.GetRelativeRef(createEpicStoryResult.Reference); //<-This is the problem; says "Could not set value for Portfolio Item: Cannot use type UserStory in attribute Portfolio Item" 
                // hierarchicalrequirement = UserStory
                CreateResult createUserStoryResult = restApi.Create("hierarchicalrequirement", toCreate);
                // -- add tasks for each UserStory
                foreach (eBayData.Models.Task t in u.Tasks)
                {
                    toCreate = new DynamicJsonObject();
                    toCreate["Name"] = t.Name;
                    toCreate["Description"] = t.Description;
                    toCreate["WorkProduct"] = Ref.GetRelativeRef(createUserStoryResult.Reference);
                    // task
                    CreateResult createUserStoryTaskResult = restApi.Create("task", toCreate);
                }
            }
        }

RallAPI:如何创建UserStory并将其与EpicStory相关联

从API和Rally UI来看,我认为您需要将问题行从toCreate["PortfolioItem"]更改为toCreate["Parent"]