如何使用 JAVA 测试 API 从 Rally 工作项下载附件?
How can I download attachments from a Rally workitem using JAVA Rest API?
我找不到适用的示例。
我从 How do I read the attachment content on a Defect
下面试过
但我得到一个 ClasscastException
,因为 JsonObject
无法转换为 JsonArray
for
JsonArray attachmentsJsonArray = existUserStoryJsonObject.getAsJsonArray("Attachments");
QueryRequest existUserStoryRequest = new QueryRequest("HierarchicalRequirement");
existUserStoryRequest.setFetch(new Fetch("FormattedID","Name","Attachments"));
existUserStoryRequest.setQueryFilter(new QueryFilter("FormattedID", "=", existStoryFormattedID));
QueryResponse userStoryQueryResponse = restApi.query(existUserStoryRequest);
JsonObject existUserStoryJsonObject = userStoryQueryResponse.getResults().get(0).getAsJsonObject();
String existUserStoryRef = userStoryQueryResponse.getResults().get(0).getAsJsonObject().get("_ref").toString();
JsonArray attachmentsJsonArray = existUserStoryJsonObject.getAsJsonArray("Attachments");
需要进行一些小的更新才能使旧答案中引用的代码与 CA Agile Central Webservices v2.0 一起使用。您可以在此处找到该示例的修改版本:
https://github.com/markwilliams970/rally-java-rest-apps/blob/master/AttachmentDownloadFromStory.java
包括 WSAPI v2.0 更新。
我找不到适用的示例。 我从 How do I read the attachment content on a Defect
下面试过但我得到一个 ClasscastException
,因为 JsonObject
无法转换为 JsonArray
for
JsonArray attachmentsJsonArray = existUserStoryJsonObject.getAsJsonArray("Attachments");
QueryRequest existUserStoryRequest = new QueryRequest("HierarchicalRequirement");
existUserStoryRequest.setFetch(new Fetch("FormattedID","Name","Attachments"));
existUserStoryRequest.setQueryFilter(new QueryFilter("FormattedID", "=", existStoryFormattedID));
QueryResponse userStoryQueryResponse = restApi.query(existUserStoryRequest);
JsonObject existUserStoryJsonObject = userStoryQueryResponse.getResults().get(0).getAsJsonObject();
String existUserStoryRef = userStoryQueryResponse.getResults().get(0).getAsJsonObject().get("_ref").toString();
JsonArray attachmentsJsonArray = existUserStoryJsonObject.getAsJsonArray("Attachments");
需要进行一些小的更新才能使旧答案中引用的代码与 CA Agile Central Webservices v2.0 一起使用。您可以在此处找到该示例的修改版本:
https://github.com/markwilliams970/rally-java-rest-apps/blob/master/AttachmentDownloadFromStory.java
包括 WSAPI v2.0 更新。