我正在尝试确定如何使用Java Rally API为Rally中的缺陷提取讨论数据。不幸的是,我找不到在线帮助或告诉我如何执行此操作的文档的帮助。我能够获取讨论数据的URL并将其作为JSON元素返回,但是我不确定如何执行查询该URL的最后一步以将讨论作为另一个JSON对象获取-我非常感谢帮助!

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"

最佳答案

如果在该URL上执行GetRequest,您将获得对话帖子的集合。方便的提示在这里:https://rally1.rallydev.com/slm/doc/webservice/

09-27 18:21