我尝试将讨论添加到用户故事中。部分代码
QueryResponse storyQueryResponse = restApi.query(storyRequest);
JsonObject storyJsonObject = storyQueryResponse.getResults().get(0).getAsJsonObject();
String storyRef = storyJsonObject.get("_ref").toString();
System.out.println("Ref: " + storyRef);
Ref ref = new Ref();
System.out.println(ref.getOidFromRef(storyRef));
System.out.println(ref.isRef(storyRef));
createDis.addProperty("Artifact", ref.getOidFromRef(storyRef));
createDis.addProperty("Text", "Java-Java-Java-Java-Java-Java-Java-Java-Java-Java-Java-Java");
CreateRequest createRequest = new CreateRequest("ConversationPost", createDis);
CreateResponse createResponse = restApi.create(createRequest);
System.out.println(“Ref:”+ storyRef)返回 参考:“https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement/13097497257”
ref.getOidFromRef(storyRef)返回NULL ref.isRef(storyRef)返回FALSE
为什么???
答案 0 :(得分:0)
此行无效,导致您的引号周围有一组额外的引号:
String storyRef = storyJsonObject.get("_ref").toString();
将其更改为此应该可以使其正常工作:
String storyRef = storyJsonObject.get("_ref").getAsString();
始终使用getAs方法而不是toString。