我尝试将讨论添加到用户故事。部分代码
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
为什么???
最佳答案
这行是无效的,并导致您的引用在其周围加上引号:
String storyRef = storyJsonObject.get("_ref").toString();
将其更改为此应该可以使其正常工作:
String storyRef = storyJsonObject.get("_ref").getAsString();
始终使用getAs方法而不是toString。