Rally API忽略查询中格式化ID的用户故事字母

时间:2013-09-06 12:10:17

标签: c# rally

我正在使用像US1, US4这样的参数在我的积压中搜索用户故事。但是,当客户端尝试使用字母F查询功能时,会检索到具有相同编号的用户素材。

然后我测试了一个缺陷 - 查询DE1检索US1。但是,查询任何字母XX1也将检索美国和给定的#。我的查询代码是:

public HierarchicalRequirement getUserStoryById(string _formattedID)
    {
        // I created this class with only the properties (bellow) I'm using
        HierarchicalRequirement userStory = null;

        Request storyRequest = new Request("hierarchicalrequirement")
        {
            ProjectScopeUp = false,
            ProjectScopeDown = true,
            Fetch = new List<string>() 
            {
                "Name",
                "ObjectID",
                "FormattedID",
                "LastUpdateDate", 
                "Owner", 
                "Children", 
                "Description", 
                "RevisionHistory", 
                "Revisions"
            },
            Query = new Query("FormattedID", Query.Operator.Equals, _formattedID)
        };

        try
        {
            QueryResult queryStoryResults = m_rallyApi.Query(storyRequest);
            if (queryStoryResults.Results.Count() > 0)
            {
                var myStory = queryStoryResults.Results.First();

                //Recursively gets a HierarchicalRequirement and its child by the reference value
                userStory = GetUserStoryByReference(myStory["_ref"]);
            }
        }
        catch (...){
        }

        return userStory;
    }

我错过了一些非常明显的东西吗?为什么我不能查询用户故事以外的任何内容?当我第一次创建Request对象时,它应该与new Request("hierarchicalrequirement")(可能是“缺陷”或“功能”)不同吗?

谢谢

1 个答案:

答案 0 :(得分:2)

请求必须指定工作项类型。使用“hierarchicalrequirement”意图查询缺陷,功能,测试用例,任务将无法正常工作。 FormattedID在同一工作空间中是唯一的,但您可以在同一工作空间中使用DE123,US123和TA123和TS123,并且必须相应地设置工作项类型。

以下是查询缺陷的示例:

        class Program
        {
            static void Main(string[] args)
            {

                RallyRestApi restApi = new RallyRestApi("user@co.com", "secret", "https://rally1.rallydev.com", "v2.0");
                String workspaceRef = "/workspace/1111";
                String projectRef = "/project/2222";

                Request dRequest = new Request("Defect");
                dRequest.Workspace = workspaceRef;
                dRequest.Project = projectRef;

                dRequest.Fetch = new List<string>()
                    {
                        "Name",
                        "FormattedID",
                    };

                var fid = "DE1";

                dRequest.Query = new Query("FormattedID", Query.Operator.Equals, fid);
                QueryResult queryResults = restApi.Query(dRequest);
                DynamicJsonObject defect = queryResults.Results.First();
                String defectRef = defect["_ref"];
                Console.WriteLine(defectRef);
                Console.WriteLine("FormattedID: " + defect["FormattedID"] + " Name: " + defect["Name"]);
//...........