How to retrieve the test case ID or TCID from Rally using Rally REST API

Trying to integrate Rally using Java, then you are reading the right post.

Download the jars needed which would be:

  • rally-rest-api-2.0.1.jar
  • gson-2.2.4.jar
The code below takes the TCID as the input and returns a reference to the test case that you can use as need be.

        String host = "";
        String username = configProp.getProperty("RallyUserName");
        String password = configProp.getProperty("RallyPassword");
        String wsapiVersion = "v2.0";
        String workspaceRef = "/workspace/11111"; 
        String applicationName = "Rest_FindTC";

   RallyRestApi restApi = new RallyRestApi(
           new URI(host),
   // Query to get the ref from Rally for the test case
   QueryRequest testCaseRequest = new QueryRequest("TestCase");
   testCaseRequest.setFetch(new Fetch("FormattedID","Name"));
   testCaseRequest.setQueryFilter(new QueryFilter("FormattedID", "=", TCID));
   QueryResponse testCaseQueryResponse = restApi.query(testCaseRequest);
   String testCaseRef = testCaseQueryResponse.getResults().get(0).getAsJsonObject().get("_ref").getAsString(); 
   testCaseRef = testCaseRef.replace("", "");
   logger.debug("For the Rally TCID: "+TCID+ " retreived from Rally the ID - "+testCaseRef);

In the above code TCID is the parameter that is passed which has the rally test case id. and testCaseRef is what is returned

Happy automated integration!


Popular posts from this blog

XPATH for IE / internet explorer

RPA - Blue Prism, OpenSpan, Automation Anywhere vs UIPath