1

我登录后做的第一件事是获取我所有工作区名称的列表;更新到最新的 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
                                            }
4

1 回答 1

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);
                }
            }
        }
    }
于 2013-08-23T15:55:28.073 回答