且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Java 中使用 Rally Rest API 获取测试集 ID?

更新时间:2021-10-06 00:36:41

您可能在查询中遇到错误.这样的代码应该可以工作.如果查询有问题,else 子句还可以帮助您诊断遇到的错误.

You're probably getting an error in your query. Code like this should work. The else clause will also help you diagnose what errors you are getting if there is a problem with your query.

QueryRequest testsetRequest = new QueryRequest("TestSet"); //no spaces
testsetRequest.setFetch(new Fetch("FormattedID","Name"));     

//No need to specify type again 
testsetRequest.setQueryFilter(new QueryFilter("Name", "=", "TestSetName")); 
QueryResponse testSetQueryResponse = restApi.query(testsetRequest);

if(testSetQueryResponse.wasSuccessful()) {
    for (JsonElement result : testSetQueryResponse.getResults()) {
        //handle results
    }
} else {
    //See what error occurred
    for (String err : testSetQueryResponse.getErrors()) {
        System.err.println("\t" + err);
    }
}