gpt4 book ai didi

java - 如何使用 Java Rally API 获取给定缺陷的讨论

转载 作者:行者123 更新时间:2023-12-02 04:31:08 25 4
gpt4 key购买 nike

我正在尝试确定如何使用 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/

关于java - 如何使用 Java Rally API 获取给定缺陷的讨论,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56584452/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com