1
votes

Using the java Rally Rest API 2.0, when I read the TestSets property of a TestCase it returns:

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

The count is correct, but how to I get the objectID values for the TestSets? The 31169145174 is the object ID of my TestCase.

1

1 Answers

1
votes

Assuming you have the testCase in a JsonObject variable called testCaseJsonObject, something similar to the following should work to poll the TestSets collection:

    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());
    }