我找不到适合的示例。 我从下面的方法中尝试了如何阅读缺陷上的附件内容
但是我得到了ClasscastException
因为无法将JsonObject
JsonArray
为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更新。