Rally .NET:查询属于特定项目的项目管理员?

时间:2017-05-02 20:22:45

标签: c# web-services rally

我正在寻找一个List对象,该对象使用项目管理员填充特定工作区内的特定项目。 想要一些示例代码可以查询API以检索所有项目管理员电子邮件地址。 这是我尝试过的一些示例代码。

    public void getProjectAdmins(string workspaceRef, string projectRef)
    {
        this.EnsureRallyIsAuthenticated();

        Request projectAdminRequest = new Request("User");
        projectAdminRequest.Workspace = workspaceRef;
        projectAdminRequest.Project = projectRef;
        projectAdminRequest.ProjectScopeUp = RallyConstant.ProjectScopeUp;
        projectAdminRequest.ProjectScopeDown = RallyConstant.ProjectScopeDown;

        projectAdminRequest.Fetch = new List<string>()
        {
            "Admin", "Email"
        };

        try
        {
            //query the items in the list
            projectAdminRequest.Query = new Query();
            QueryResult result = _rallyRestApi.Query(projectAdminRequest);

            //iterate through the result set
            foreach (var admin in result.Results)
            {
                var adminResult = admin[RallyConstant.Owner];
                if (adminResult != null)
                {
                    var x = adminResult[RallyQueryConstant.ReferenceObject];

                }
            }
        }
        catch (WebException)
        {
            Console.WriteLine(RallyQueryConstant.WebExceptionMessage);
        }
    }

1 个答案:

答案 0 :(得分:1)

您应该能够查询过滤到您所讨论的项目的ProjectPermission端点,如下所示:

Request projectAdminRequest = new Request("ProjectPermission");
projectAdminRequest.Workspace = workspaceRef;
projectAdminRequest.Fetch = new List<string>() {"User", "EmailAddress"};
projectAdminRequest.Query = Query.And(
    new Query("Project", Query.Operator.Equals, "/project/12345"),
    new Query("Role", Query.Operator.Equals, "Project Admin"));

获取用户和EmailAddress应包含您在请求中查找的数据。