使用Rally的.Net API来提取所有工作区的列表?

时间:2013-08-23 13:20:37

标签: .net api rally

登录时我要做的第一件事是获取所有工作区名称的列表;更新到最新的DLL后,我当前的方法不起作用。需要改变什么?代码如下:

DynamicJsonObject sub = loginRestApi.GetSubscription(“Workspaces”);

                var workspaceNames = sub["Workspaces"];

                iterations.Clear();
                projects.Clear();
                tVFROPGenerator.Nodes.Clear();
                tVlistDomainStatus.Nodes.Clear();
                cbProject.Items.Clear();
                cbProject.Items.Add(ALL_PROJECTS);
                int indexWorkspace = 0;

                foreach (var workspaceRef in sub["Workspaces"])  <-----THIS GIVES ME THE ERROR
                {
                       //DO QUERIES/OTHER
                                            }

1 个答案:

答案 0 :(得分:0)

请尝试以下代码:

    using System;
    using System.Collections.Generic;
    using System.Collections;
    using System.Linq;
    using System.Text;
    using Rally.RestApi;
    using Rally.RestApi.Response;

    namespace Rest_v2._0_test
    {
        class Program
        {
            static void Main(string[] args)
            {
                //Initialize the REST API
                RallyRestApi restApi;
                restApi = new RallyRestApi("user@co.com", "secret", "https://rally1.rallydev.com", "v2.0");

                //get the current subscription
                DynamicJsonObject sub = restApi.GetSubscription("Workspaces");

                Request wRequest = new Request(sub["Workspaces"]);

                //query the Workspaces collection
                QueryResult queryResult = restApi.Query(wRequest);

               foreach (var result in queryResult.Results)
                {
                    var workspaceReference = result["_ref"];
                    var workspaceName = result["Name"];
                    Console.WriteLine( workspaceName + " " + workspaceReference);
                }
            }
        }
    }