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

标签 java rest rally

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

相关文章:

java - Mac 上的 Snappy 在 Hadoop 上执行 Avro 作业时出现问题

json - 使用 Go 的 restful Web 服务的 POST 方法(对于 JSON)的 Curl 命令的 500 内部服务器错误

java - 在 Java 中创建不可编辑的数据文件

java - Android studio,从插入类的类中继承变量

java - 对数组的整数进行排序

javascript - 处理 Rally 数据存储中的空异常

rally - 迭代燃尽图大小未得到遵守?

security - 如何安全地使用敏感数据进行 REST?

c# - 从 C# 调用 REST API

python-3.x - 当前工作区 |ABC|不包含与项目 : None 的当前设置匹配的项目