我正在尝试确定如何使用Java Rally API为Rally中的缺陷提取讨论数据。不幸的是,我在网上或文档中找不到任何帮助,该文档告诉我如何执行此操作。我能够获取讨论数据的URL并将其作为JSON元素返回,但是我不确定如何执行查询该URL的最后一步以将讨论作为另一个JSON对象获得-我非常感谢帮助! / p>
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.rallydev.rest.RallyRestApi;
import com.rallydev.rest.request.*;
import com.rallydev.rest.response.*;
import com.rallydev.rest.util.Fetch;
import com.rallydev.rest.util.QueryFilter;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
public class ExtractDiscussions
{
public static void main(String args[]) throws URISyntaxException, IOException {
RallyRestApi restApi = new RallyRestApi(new URI("https://rally1.rallydev.com"), "myApiKey");
restApi.setApplicationName("DANA Example");
restApi.setProxy(new URI("myProxy"),"myUsername","myPassword");
try {
QueryRequest defectRequest = new QueryRequest("defect");
defectRequest.setQueryFilter(new QueryFilter("FormattedID","=","DE123456"));
defectRequest.setFetch(new Fetch());
//defectRequest.setPageSize(25);
//defectRequest.setLimit(100);
QueryResponse queryResponse = restApi.query(defectRequest);
System.out.println(queryResponse.getTotalResultCount());
JsonObject obj = queryResponse.getResults().get(0).getAsJsonObject();
obj = obj.getAsJsonObject("Discussion");
JsonElement discussionLink = obj.get("_ref");
System.out.println(discussionLink);
//Code would go here to fetch the discussion using the discussion link
}finally{
restApi.close();
}
}
}
我的结果:
1
"https://rally1.rallydev.com/slm/webservice/v2.0/Defect/1321234562/Discussion"
答案 0 :(得分:0)
如果您在该URL上执行GetRequest,您将获得对话帖子的集合。方便的提示在这里:https://rally1.rallydev.com/slm/doc/webservice/