【问题标题】:How to read a collection property from Rally Rest API如何从 Rally Rest API 读取集合属性
【发布时间】:2015-04-29 14:13:45
【问题描述】:

使用 java Rally Rest API 2.0,当我读取 TestCase 的 TestSets 属性时,它返回:

{"_rallyAPIMajor":"2","_rallyAPIMinor":"0","_ref":"https://rally1.rallydev.com/slm/webservice/v2.0/TestCase/31169145174/TestSets", "_type":"TestSet","Count":3}

计数是正确的,但是如何获取测试集的 objectID 值? 31169145174 是我的 TestCase 的对象 ID。

【问题讨论】:

    标签: java api rest collections rally


    【解决方案1】:

    假设您在名为 testCaseJsonObjectJsonObject 变量中有 testCase,类似于以下内容的内容应该可以轮询 TestSets 集合:

        QueryRequest testSetRequest = new QueryRequest(testCaseJsonObject.getAsJsonObject("TestSets"));
        testSetRequest.setFetch(new Fetch("Name", "FormattedID"));
    
        // Load the TestSet collection
        JsonArray testSetsOfTestCase = restApi.query(testSetRequest).getResults();
    
        for (int i=0; i<testSetsOfTestCase.length(); i++) {
            System.out.println("Name: " + testSetsOfTestCase.get(i).getAsJsonObject().get("Name") + testSetsOfTestCase.get(i).getAsJsonObject().get("FormattedID").getAsString());
        }
    

    【讨论】:

      猜你喜欢
      • 2017-08-21
      • 2020-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-13
      • 2015-10-14
      • 1970-01-01
      相关资源
      最近更新 更多