我找不到这样的工作示例。我尝试了下面的"如何阅读缺陷上的附件内容"
但我得到了一个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更新。