我找不到适合的示例。
我从How do I read the attachment content on a Defect尝试以下

但我得到一个ClasscastException,因为JsonObject不能转换为JsonArray

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更新。

10-06 16:16